summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pear/Console/Getopt.php27
1 files changed, 8 insertions, 19 deletions
diff --git a/pear/Console/Getopt.php b/pear/Console/Getopt.php
index b4aa005bfb..da6f1dd1c0 100644
--- a/pear/Console/Getopt.php
+++ b/pear/Console/Getopt.php
@@ -119,7 +119,7 @@ class Console_Getopt {
/* 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 @@ class Console_Getopt {
} 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 @@ class Console_Getopt {
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 @@ class Console_Getopt {
/* 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 @@ class Console_Getopt {
{
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'];
}
@@ -217,15 +217,4 @@ class Console_Getopt {
}
-
-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);
- }
-}
-
?>