From 6b5173f035677aba1a1b83fbb73dc1122f10cacf Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sat, 12 May 2007 12:25:56 +0000 Subject: [PATCH] - Handle regex parameters in clicommand --- ext/phar/phar/clicommand.inc | 19 +++++++++++++++++++ ext/phar/phar/pharcommand.inc | 8 ++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ext/phar/phar/clicommand.inc b/ext/phar/phar/clicommand.inc index d65016afde..e9b040ba46 100755 --- a/ext/phar/phar/clicommand.inc +++ b/ext/phar/phar/clicommand.inc @@ -175,6 +175,25 @@ abstract class CLICommand return (bool)$arg; } + static function cli_arg_typ_regex($arg) + { + if (strlen($arg)) + { + if (strlen($arg) > 1 && $arg[0] == $arg[strlen($arg)-1] && strpos('/,', $arg) !== false) + { + return $arg; + } + else + { + return '/' . $arg . '/'; + } + } + else + { + return NULL; + } + } + static function cli_arg_typ_select($arg, $cfg) { if (!in_array($arg, array_keys($cfg['select']))) diff --git a/ext/phar/phar/pharcommand.inc b/ext/phar/phar/pharcommand.inc index 14788bfc59..c7ad530327 100755 --- a/ext/phar/phar/pharcommand.inc +++ b/ext/phar/phar/pharcommand.inc @@ -191,12 +191,12 @@ class PharCommand extends CLICommand if (isset($regex)) { - $dir = new RegexIterator($dir, '/'. $regex . '/'); + $dir = new RegexIterator($dir, $regex); } if (isset($invregex)) { - $dir = new InvertedRegexIterator($dir, '/'. $invregex . '/'); + $dir = new InvertedRegexIterator($dir, $invregex); } try @@ -231,12 +231,12 @@ class PharCommand extends CLICommand if (isset($regex)) { - $dir = new RegexIterator($dir, '/'. $regex . '/'); + $dir = new RegexIterator($dir, $regex); } if (isset($invregex)) { - $dir = new InvertedRegexIterator($dir, '/'. $invregex . '/'); + $dir = new InvertedRegexIterator($dir, $invregex); } foreach($dir as $pn => $f) -- 2.50.1