cvs: php4 /pear/Console Getopt.php

From: Date: Fri, 05 Oct 2001 01:32:13 +0000
Subject: cvs: php4 /pear/Console Getopt.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-928@lists.php.net to get a copy of this message
cox Thu Oct 4 21:32:13 2001 EDT Modified files: /php4/pear/Console Getopt.php Log: E_ALL fixes Index: php4/pear/Console/Getopt.php diff -u php4/pear/Console/Getopt.php:1.3 php4/pear/Console/Getopt.php:1.4 --- php4/pear/Console/Getopt.php:1.3 Tue May 29 12:18:35 2001 +++ php4/pear/Console/Getopt.php Thu Oct 4 21:32:13 2001 @@ -17,7 +17,7 @@ // | Authors: Andrei Zmievski <andrei@ispi.net> | // +----------------------------------------------------------------------+ // -// $Id: Getopt.php,v 1.3 2001/05/29 16:18:35 andrei Exp $ +// $Id: Getopt.php,v 1.4 2001/10/05 01:32:13 cox Exp $ require_once 'PEAR.php'; @@ -53,7 +53,7 @@ * 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 @@ 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 @@ 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;

« previous php.pear.cvs (#928) next »