cvs: php-src(PHP_5_2) /sapi/cli getopt.c /sapi/cli/tests 015.phpt

From: Date: Thu, 22 Mar 2007 21:35:41 +0000
Subject: cvs: php-src(PHP_5_2) /sapi/cli getopt.c /sapi/cli/tests 015.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-43612@lists.php.net to get a copy of this message
johannes Thu Mar 22 21:35:41 2007 UTC Added files: (Branch: PHP_5_2) /php-src/sapi/cli/tests 015.phpt Modified files: /php-src/sapi/cli getopt.c Log: - MFH: Fix handling of not existing long CLI options http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/getopt.c?r1=1.8.2.1.2.2&r2=1.8.2.1.2.3&diff_format=u Index: php-src/sapi/cli/getopt.c diff -u php-src/sapi/cli/getopt.c:1.8.2.1.2.2 php-src/sapi/cli/getopt.c:1.8.2.1.2.3 --- php-src/sapi/cli/getopt.c:1.8.2.1.2.2 Wed Mar 21 23:20:21 2007 +++ php-src/sapi/cli/getopt.c Thu Mar 22 21:35:41 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: getopt.c,v 1.8.2.1.2.2 2007/03/21 23:20:21 helly Exp $ */ +/* $Id: getopt.c,v 1.8.2.1.2.3 2007/03/22 21:35:41 johannes Exp $ */ #include <stdio.h> #include <string.h> @@ -79,11 +79,16 @@ } 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; } http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/tests/015.phpt?view=markup&rev=1.1 Index: php-src/sapi/cli/tests/015.phpt +++ php-src/sapi/cli/tests/015.phpt --TEST-- CLI long options --SKIPIF-- <?php include "skipif.inc"; ?> --FILE-- <?php $php = getenv('TEST_PHP_EXECUTABLE'); echo "$php" --version | grep built:; echo echo "<?php print_r(\\\$argv);" | "$php" -- foo bar baz, "\n"; echo "$php" --version foo bar baz | grep built:; echo "$php" --notexisting foo bar baz | grep Usage:; echo "Done\n"; ?> --EXPECTF-- PHP %d.%d.%d%s(cli) (built: %s) Array ( [0] => - [1] => foo [2] => bar [3] => baz ) PHP %d.%d.%d%s(cli) (built: %s) Usage: php [options] [-f] <file> [--] [args...] Done

« previous php.cvs (#43612) next »