cvs: pear-core / package-Console_Getopt.xml package2-Console_Getopt.xml /Console Getopt.php

From: Date: Sun, 18 Feb 2007 04:13:07 +0000
Subject: cvs: pear-core / package-Console_Getopt.xml package2-Console_Getopt.xml /Console Getopt.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-5444@lists.php.net to get a copy of this message
cellog Sun Feb 18 04:13:07 2007 UTC Modified files: /pear-core package2-Console_Getopt.xml package-Console_Getopt.xml /pear-core/Console Getopt.php Log: fix Bug #10055: Not failing properly on short options missing required values http://cvs.php.net/viewvc.cgi/pear-core/package2-Console_Getopt.xml?r1=1.1&r2=1.2&diff_format=u Index: pear-core/package2-Console_Getopt.xml diff -u pear-core/package2-Console_Getopt.xml:1.1 pear-core/package2-Console_Getopt.xml:1.2 --- pear-core/package2-Console_Getopt.xml:1.1 Thu Feb 1 23:35:34 2007 +++ pear-core/package2-Console_Getopt.xml Sun Feb 18 04:13:07 2007 @@ -27,7 +27,7 @@ <email>cellog@php.net</email> <active>yes</active> </helper> - <date>2007-02-01</date> + <date>2007-02-17</date> <version> <release>1.2.2</release> <api>1.2.1</api> @@ -37,7 +37,9 @@ <api>stable</api> </stability> <license uri="http://www.php.net/license">PHP License</license> - <notes>* fix Bug #4475: An ambiguous error occurred when specifying similar longoption name. + <notes> + * fix Bug #4475: An ambiguous error occurred when specifying similar longoption name. + * fix Bug #10055: Not failing properly on short options missing required values </notes> <contents> <dir name="/"> @@ -46,6 +48,12 @@ </dir> <!-- //Console --> </dir> <!-- / --> </contents> + <compatible> + <name>PEAR</name> + <channel>pear.php.net</channel> + <min>1.4.0</min> + <max>1.5.0</max> + </compatible> <dependencies> <required> <php> http://cvs.php.net/viewvc.cgi/pear-core/package-Console_Getopt.xml?r1=1.12&r2=1.13&diff_format=u Index: pear-core/package-Console_Getopt.xml diff -u pear-core/package-Console_Getopt.xml:1.12 pear-core/package-Console_Getopt.xml:1.13 --- pear-core/package-Console_Getopt.xml:1.12 Thu Feb 1 05:27:30 2007 +++ pear-core/package-Console_Getopt.xml Sun Feb 18 04:13:07 2007 @@ -30,9 +30,10 @@ </maintainers> <release> <version>1.2.2</version> - <date>2007-02-05</date> + <date>2007-02-17</date> <notes> * fix Bug #4475: An ambiguous error occurred when specifying similar longoption name. + * fix Bug #10055: Not failing properly on short options missing required values </notes> <state>stable</state> <filelist> http://cvs.php.net/viewvc.cgi/pear-core/Console/Getopt.php?r1=1.31&r2=1.32&diff_format=u Index: pear-core/Console/Getopt.php diff -u pear-core/Console/Getopt.php:1.31 pear-core/Console/Getopt.php:1.32 --- pear-core/Console/Getopt.php:1.31 Thu Feb 1 05:32:44 2007 +++ pear-core/Console/Getopt.php Sun Feb 18 04:13:07 2007 @@ -16,7 +16,7 @@ // | Author: Andrei Zmievski <andrei@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Getopt.php,v 1.31 2007/02/01 05:32:44 cellog Exp $ +// $Id: Getopt.php,v 1.32 2007/02/18 04:13:07 cellog Exp $ require_once 'PEAR.php'; @@ -167,10 +167,14 @@ if ($i + 1 < strlen($arg)) { $opts[] = array($opt, substr($arg, $i + 1)); break; - } else if (list(, $opt_arg) = each($args)) + } else if (list(, $opt_arg) = each($args)) { /* Else use the next argument. */; - else + if (Console_Getopt::_isShortOpt($opt_arg) || Console_Getopt::_isLongOpt($opt_arg)) { + return PEAR::raiseError("Console_Getopt: option requires an argument -- $opt"); + } + } else { return PEAR::raiseError("Console_Getopt: option requires an argument -- $opt"); + } } } @@ -182,6 +186,25 @@ * @access private * */ + function _isShortOpt($arg) + { + return strlen($arg) == 2 && $arg[0] == '-' && preg_match('/[a-zA-Z]/', $arg[1]); + } + + /** + * @access private + * + */ + function _isLongOpt($arg) + { + return strlen($arg) > 2 && $arg[0] == '-' && $arg[1] == '-' && + preg_match('/[a-zA-Z]+$/', substr($arg, 2)); + } + + /** + * @access private + * + */ function _parseLongOption($arg, $long_options, &$opts, &$args) { @list($opt, $opt_arg) = explode('=', $arg, 2);

« previous php.pear.core (#5444) next »