From a9ad07045a2f21ca1ec39ca5e7d636a61e4705ab Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Wed, 6 Aug 2008 14:20:36 +0000 Subject: debuged, added basic tests --- it.class | 4 ++-- tests/getopt.t | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 tests/getopt.t diff --git a/it.class b/it.class index ab56894..d64559c 100644 --- a/it.class +++ b/it.class @@ -518,7 +518,7 @@ function getopt($helplines) $witharg[$longoptname ? $longoptname : $shortoptname] = $longoptarg || $shortoptarg; } } - $witharg['debug'] = 1; + $witharg['debug'] = true; $mandatoryargs = array(); if ($tmp = trim(it::replace(array("\n.*" => "", "^\S+\s+\S+\s*" => "", "\[.*?\]\s*" => ""), trim($helplines)))) @@ -533,7 +533,7 @@ function getopt($helplines) else $result[array_shift($eat)] = $arg; } - elseif ($matches = (array)it::match('^--(\w[\w-]*)(=\S*)?', $arg)) + elseif ($matches = (array)it::match('^--(\w[\w-]*)(=.*)?', $arg)) { list($optname, $val) = $matches; if (!isset($witharg[$optname]) || isset($val) && !$witharg[$optname]) diff --git a/tests/getopt.t b/tests/getopt.t new file mode 100755 index 0000000..41e985d --- /dev/null +++ b/tests/getopt.t @@ -0,0 +1,24 @@ +#!/www/server/bin/php -qC +