diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-01-27 13:32:29 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-01-27 13:32:38 +0100 |
commit | 1cccbb8ff1339c44075e7dee8613d98dc8056f68 (patch) | |
tree | 3eb848778ca364b6a819b684b4ee6c694ef693c1 /main | |
parent | 41e1891e0c2c4d9c3827d8e95dff735eee38268d (diff) | |
parent | fd08f062ae5a3c92bfc0345da7e83ab320046864 (diff) | |
download | php-git-1cccbb8ff1339c44075e7dee8613d98dc8056f68.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
Fix bug #78323: Code 0 is returned on invalid options
Diffstat (limited to 'main')
-rw-r--r-- | main/getopt.c | 3 | ||||
-rw-r--r-- | main/php_getopt.h | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/main/getopt.c b/main/getopt.c index c01a726e99..9123cee0f2 100644 --- a/main/getopt.c +++ b/main/getopt.c @@ -26,6 +26,7 @@ #define OPTERRNF (2) #define OPTERRARG (3) +// Print error message to stderr and return -2 to distinguish it from '?' command line option. static int php_opt_error(int argc, char * const *argv, int oint, int optchr, int err, int show_err) /* {{{ */ { if (show_err) @@ -47,7 +48,7 @@ static int php_opt_error(int argc, char * const *argv, int oint, int optchr, int break; } } - return('?'); + return PHP_GETOPT_INVALID_ARG; } /* }}} */ diff --git a/main/php_getopt.h b/main/php_getopt.h index 20746517d4..c368aa7fa9 100644 --- a/main/php_getopt.h +++ b/main/php_getopt.h @@ -35,4 +35,7 @@ extern PHPAPI int php_optidx; PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err, int arg_start); END_EXTERN_C() +/* php_getopt will return this value if there is an error in arguments */ +#define PHP_GETOPT_INVALID_ARG (-2) + #endif |