]> granicus.if.org Git - php/commitdiff
Add missing loop variable $i.
authorMarkus Fischer <mfischer@php.net>
Sun, 11 Nov 2001 04:09:08 +0000 (04:09 +0000)
committerMarkus Fischer <mfischer@php.net>
Sun, 11 Nov 2001 04:09:08 +0000 (04:09 +0000)
Suppress more warnings when using the option separator '--'.

pear/Console/Getopt.php

index 41ea43d27f2aca92fe1311291953f6e2fc42cb0c..b20bc6754ac70394c203a1eb9d38df9791b8668c 100644 (file)
@@ -75,7 +75,7 @@ class Console_Getopt {
             sort($long_options);
 
         reset($args);
-        while (list(, $arg) = each($args)) {
+        while (list($i, $arg) = each($args)) {
 
             /* The special element '--' means explicit end of options. Treat the
                rest of the arguments as non-options and end the loop. */
@@ -84,9 +84,9 @@ class Console_Getopt {
                 break;
             }
 
-            if ($arg{0} != '-' || ($arg{1} == '-' && !$long_options)) {
+            if ($arg{0} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options)) {
                 $non_opts[] = $arg;
-            } else if ($arg{1} == '-') {
+            } else if (strlen($arg) > 1 && $arg{1} == '-') {
                 $error = Console_Getopt::_parseLongOption(substr($arg, 2), $long_options, $opts, $args);
                 if (PEAR::isError($error))
                     return $error;