From 062443ea9794a1177bb0a19b17e965dff074e7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schl=C3=BCter?= Date: Thu, 22 Mar 2007 21:35:56 +0000 Subject: - MFH: Fix handling of not existing long CLI options --- sapi/cli/getopt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sapi/cli/getopt.c') diff --git a/sapi/cli/getopt.c b/sapi/cli/getopt.c index dd44703803..fbe97e2f9f 100644 --- a/sapi/cli/getopt.c +++ b/sapi/cli/getopt.c @@ -79,11 +79,16 @@ int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **opta } if ((argv[*optind][0] == '-') && (argv[*optind][1] == '-')) { /* '--' indicates end of args if not followed by a known long option name */ + if (argv[*optind][2] == '\0') { + (*optind)++; + return(EOF); + } + while (1) { opts_idx++; if (opts[opts_idx].opt_char == '-') { (*optind)++; - return(EOF); + return(php_opt_error(argc, argv, *optind-1, optchr, OPTERRARG, show_err)); } else if (opts[opts_idx].opt_name && !strcmp(&argv[*optind][2], opts[opts_idx].opt_name)) { break; } -- cgit v1.2.1