cvs: php4 /pear/Console Getopt.php

From: Date: Sat, 11 May 2002 16:39:40 +0000
Subject: cvs: php4 /pear/Console Getopt.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-3758@lists.php.net to get a copy of this message
ssb Sat May 11 12:39:40 2002 EDT Modified files: /php4/pear/Console Getopt.php Log: * use PEAR::raiseError Index: php4/pear/Console/Getopt.php diff -u php4/pear/Console/Getopt.php:1.11 php4/pear/Console/Getopt.php:1.12 --- php4/pear/Console/Getopt.php:1.11 Thu Feb 28 03:27:06 2002 +++ php4/pear/Console/Getopt.php Sat May 11 12:39:39 2002 @@ -16,7 +16,7 @@ // | Author: Andrei Zmievski <andrei@ispi.net> | // +----------------------------------------------------------------------+ // -// $Id: Getopt.php,v 1.11 2002/02/28 08:27:06 sebastian Exp $ +// $Id: Getopt.php,v 1.12 2002/05/11 16:39:39 ssb Exp $ require_once 'PEAR.php'; @@ -119,7 +119,7 @@ /* Try to find the short option in the specifier string. */ if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':') { - return new Getopt_Error("unrecognized option -- $opt\n"); + return PEAR::raiseError("Console_Getopt: unrecognized option -- $opt"); } if (strlen($spec) > 1 && $spec{1} == ':') { @@ -139,7 +139,7 @@ } else if (list(, $opt_arg) = each($args)) /* Else use the next argument. */; else - return new Getopt_Error("option requires an argument -- $opt\n"); + return PEAR::raiseError("Console_Getopt: option requires an argument -- $opt"); } } @@ -171,7 +171,7 @@ if ($opt_rest != '' && $opt{0} != '=' && $i + 1 < count($long_options) && $opt == substr($long_options[$i+1], 0, $opt_len)) { - return new Getopt_Error("option --$opt is ambiguous\n"); + return PEAR::raiseError("Console_Getopt: option --$opt is ambiguous"); } if (substr($long_opt, -1) == '=') { @@ -179,18 +179,18 @@ /* Long option requires an argument. Take the next argument if one wasn't specified. */; if (!$opt_arg && !(list(, $opt_arg) = each($args))) { - return new Getopt_Error("option --$opt requires an argument\n"); + return PEAR::raiseError("Console_Getopt: option --$opt requires an argument"); } } } else if ($opt_arg) { - return new Getopt_Error("option --$opt doesn't allow an argument\n"); + return PEAR::raiseError("Console_Getopt: option --$opt doesn't allow an argument"); } $opts[] = array('--' . $opt, $opt_arg); return; } - return new Getopt_Error("unrecognized option --$opt\n"); + return PEAR::raiseError("Console_Getopt: unrecognized option --$opt"); } /** @@ -204,9 +204,9 @@ { global $argv; if (!is_array($argv)) { - if (!is_array($_SERVER['argv'])) { + if (!@is_array($_SERVER['argv'])) { if (!is_array($HTTP_SERVER_VARS['argv'])) { - return new Getopt_Error("Could not read cmd args (register_argc_argv=Off?)\n"); + return PEAR::raiseError("Console_Getopt: Could not read cmd args (register_argc_argv=Off?)"); } return $HTTP_SERVER_VARS['argv']; } @@ -215,17 +215,6 @@ return $argv; } -} - - -class Getopt_Error extends PEAR_Error { - var $classname = 'Getopt'; - var $error_message_prepend = 'Error in Getopt'; - - function Getopt_Error($message, $code = 0, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE) - { - $this->PEAR_Error($message, $code, $mode, $level); - } } ?>

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