From: Tomas V.V.Cox Date: Fri, 5 Oct 2001 01:32:13 +0000 (+0000) Subject: E_ALL fixes X-Git-Tag: PRE_PARAMETER_PARSING_API~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1f470ecca69525b080db5c856cf742644c4def3a;p=php E_ALL fixes --- diff --git a/pear/Console/Getopt.php b/pear/Console/Getopt.php index b116b20777..14931dec16 100644 --- a/pear/Console/Getopt.php +++ b/pear/Console/Getopt.php @@ -53,7 +53,7 @@ class Console_Getopt { * Long and short options can be mixed. * * Most of the semantics of this function are based on GNU getopt_long(). - * + * * @param $args array an array of command-line arguments * @param $short_options string specifies the list of allowed short options * @param $long_options array specifies the list of allowed long options @@ -116,8 +116,8 @@ class Console_Getopt { return new Getopt_Error("unrecognized option -- $opt\n"); } - if ($spec{1} == ':') { - if ($spec{2} == ':') { + if (strlen($spec) > 1 && $spec{1} == ':') { + if (strlen($spec) > 2 && $spec{2} == ':') { if ($i + 1 < strlen($arg)) { /* Option takes an optional argument. Use the remainder of the arg string if there is anything left. */ @@ -153,7 +153,7 @@ class Console_Getopt { for ($i = 0; $i < count($long_options); $i++) { $long_opt = $long_options[$i]; $opt_start = substr($long_opt, 0, $opt_len); - + /* Option doesn't match. Go on to the next one. */ if ($opt_start != $opt) continue;