#23476 [Ana->Dup]: Console::Getopt: Long option ==0 not detected

From: Date: Mon, 30 Jun 2003 10:23:41 +0000
Subject: #23476 [Ana->Dup]: Console::Getopt: Long option ==0 not detected
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-17857@lists.php.net to get a copy of this message
ID: 23476 Updated by: cox@php.net Reported By: vonderheide at redlink dot de -Status: Analyzed +Status: Duplicate Bug Type: PEAR related PHP Version: 4.3.2RC2 New Comment: This bug has been fixed in CVS, thanks (see bug #21994) Previous Comments: ------------------------------------------------------------------------ [2003-05-06 09:45:40] arnaud@php.net The following patch would do the job. Can somebody with enough GetOpt knowledge please review this patch. From my little experience it looks ok. --- Getopt.php 2003-05-06 16:43:51.000000000 +0200 +++ ../../../../tmp/php4-win32-STABLE-200305060030/PEAR/Console/Getopt.php 2003-05-06 16:42:28.000000000 +0200 @@ -3,7 +3,7 @@ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | +// | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ // | Author: Andrei Zmievski <andrei@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Getopt.php,v 1.21 2002/08/05 12:58:38 alan_k Exp $ +// $Id: Getopt.php,v 1.22 2002/12/31 16:18:25 sebastian Exp $ require_once 'PEAR.php'; @@ -183,7 +183,7 @@ if (substr($long_opt, -2) != '==') { /* Long option requires an argument. Take the next argument if one wasn't specified. */; - if (!$opt_arg && !(list(, $opt_arg) = each($args))) { + if ($opt_arg !== '' && !(list(, $opt_arg) = each($args))) { return PEAR::raiseError("Console_Getopt: option --$opt requires an argument"); } } ------------------------------------------------------------------------ [2003-05-04 07:14:45] vonderheide at redlink dot de When giving a long option as 0 (as in --offset=0), Getopt raises a "Console_Getopt: option --$opt requires an argument" error. The bug is in line 186 (current CVS): if (!$opt_arg && !(list(, $opt_arg) = each($args))) { This can be fixed by replacing !$opt_arg with $opt_arg !== '' although I haven't checked if this has any side effects. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=23476&edit=1

« previous php.pear.dev (#17857) next »