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

From: Date: Thu, 22 Mar 2007 21:34:58 +0000
Subject: cvs: php-src /sapi/cli getopt.c /sapi/cli/tests 015.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-43611@lists.php.net to get a copy of this message
johannes Thu Mar 22 21:34:58 2007 UTC Added files: /php-src/sapi/cli/tests 015.phpt Modified files: /php-src/sapi/cli getopt.c Log: - Fix handling of not existing long CLI options http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/getopt.c?r1=1.11&r2=1.12&diff_format=u Index: php-src/sapi/cli/getopt.c diff -u php-src/sapi/cli/getopt.c:1.11 php-src/sapi/cli/getopt.c:1.12 --- php-src/sapi/cli/getopt.c:1.11 Wed Mar 21 23:19:00 2007 +++ php-src/sapi/cli/getopt.c Thu Mar 22 21:34:58 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: getopt.c,v 1.11 2007/03/21 23:19:00 helly Exp $ */ +/* $Id: getopt.c,v 1.12 2007/03/22 21:34:58 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 (#43611) next »