From cc4c0634fe1bd33eabe7c5fe9004082a6822d23a Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sat, 26 Oct 2002 16:54:30 +0000 Subject: -introduce EXPECTREGEX -add %c for EXPECTF #i think we must escape the special characters for EXPECTF: ".()" and such --- run-tests.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'run-tests.php') diff --git a/run-tests.php b/run-tests.php index 841c0b0d6f..cda58ec9a9 100755 --- a/run-tests.php +++ b/run-tests.php @@ -559,17 +559,24 @@ COMMAND $cmd $output = trim($out); $output = preg_replace('/\r\n/',"\n",$output); - if (isset($section_text['EXPECTF'])) { - $wanted = trim($section_text['EXPECTF']); + if (isset($section_text['EXPECTF']) || isset($section_text['EXPECTREGEX'])) { + if (isset($section_text['EXPECTF'])) { + $wanted = trim($section_text['EXPECTF']); + } else { + $wanted = trim($section_text['EXPECTREGEX']); + } $wanted_re = preg_replace('/\r\n/',"\n",$wanted); - $wanted_re = preg_quote($wanted_re, '/'); - // Stick to basics - $wanted_re = str_replace("%s", ".+?", $wanted_re); //not greedy - $wanted_re = str_replace("%i", "[+\-]?[0-9]+", $wanted_re); - $wanted_re = str_replace("%d", "[0-9]+", $wanted_re); - $wanted_re = str_replace("%x", "[0-9a-fA-F]+", $wanted_re); - $wanted_re = str_replace("%f", "[+\-]?\.?[0-9]+\.?[0-9]*", $wanted_re); - // %f allows two points "-.0.0" but that is the best *simple* expression + if (isset($section_text['EXPECTF'])) { + $wanted_re = preg_quote($wanted_re, '/'); + // Stick to basics + $wanted_re = str_replace("%s", ".+?", $wanted_re); //not greedy + $wanted_re = str_replace("%i", "[+\-]?[0-9]+", $wanted_re); + $wanted_re = str_replace("%d", "[0-9]+", $wanted_re); + $wanted_re = str_replace("%x", "[0-9a-fA-F]+", $wanted_re); + $wanted_re = str_replace("%f", "[+\-]?\.?[0-9]+\.?[0-9]*", $wanted_re); + $wanted_re = str_replace("%c", ".", $wanted_re); + // %f allows two points "-.0.0" but that is the best *simple* expression + } /* DEBUG YOUR REGEX HERE var_dump($wanted); print(str_repeat('=', 80) . "\n"); -- cgit v1.2.1