- White space fixes

This commit is contained in:
Marcus Boerger 2005-12-01 00:57:29 +00:00
parent 2208b59602
commit ed0b0d1f33

View file

@ -1135,63 +1135,63 @@ COMMAND $cmd
} else { // normal testing } else { // normal testing
// Does the output match what is expected? // Does the output match what is expected?
$output = trim($out); $output = trim($out);
$output = preg_replace('/\r\n/',"\n",$output); $output = preg_replace('/\r\n/',"\n",$output);
/* when using CGI, strip the headers from the output */ /* when using CGI, strip the headers from the output */
if (isset($old_php) && ($pos = strpos($output, "\n\n")) !== FALSE) { if (isset($old_php) && ($pos = strpos($output, "\n\n")) !== FALSE) {
$output = substr($output, ($pos + 2)); $output = substr($output, ($pos + 2));
} }
if (isset($section_text['EXPECTF']) || isset($section_text['EXPECTREGEX'])) { if (isset($section_text['EXPECTF']) || isset($section_text['EXPECTREGEX'])) {
if (isset($section_text['EXPECTF'])) { if (isset($section_text['EXPECTF'])) {
$wanted = trim($section_text['EXPECTF']); $wanted = trim($section_text['EXPECTF']);
} else { } else {
$wanted = trim($section_text['EXPECTREGEX']); $wanted = trim($section_text['EXPECTREGEX']);
} }
$wanted_re = preg_replace('/\r\n/',"\n",$wanted); $wanted_re = preg_replace('/\r\n/',"\n",$wanted);
if (isset($section_text['EXPECTF'])) { if (isset($section_text['EXPECTF'])) {
$wanted_re = preg_quote($wanted_re, '/'); $wanted_re = preg_quote($wanted_re, '/');
// Stick to basics // Stick to basics
$wanted_re = str_replace("%e", '\\' . DIRECTORY_SEPARATOR, $wanted_re); $wanted_re = str_replace("%e", '\\' . DIRECTORY_SEPARATOR, $wanted_re);
$wanted_re = str_replace("%s", ".+?", $wanted_re); //not greedy $wanted_re = str_replace("%s", ".+?", $wanted_re); //not greedy
$wanted_re = str_replace("%i", "[+\-]?[0-9]+", $wanted_re); $wanted_re = str_replace("%i", "[+\-]?[0-9]+", $wanted_re);
$wanted_re = str_replace("%d", "[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("%x", "[0-9a-fA-F]+", $wanted_re);
$wanted_re = str_replace("%f", "[+\-]?\.?[0-9]+\.?[0-9]*(E-?[0-9]+)?", $wanted_re); $wanted_re = str_replace("%f", "[+\-]?\.?[0-9]+\.?[0-9]*(E-?[0-9]+)?", $wanted_re);
$wanted_re = str_replace("%c", ".", $wanted_re); $wanted_re = str_replace("%c", ".", $wanted_re);
// %f allows two points "-.0.0" but that is the best *simple* expression // %f allows two points "-.0.0" but that is the best *simple* expression
} }
/* DEBUG YOUR REGEX HERE /* DEBUG YOUR REGEX HERE
var_dump($wanted_re); var_dump($wanted_re);
print(str_repeat('=', 80) . "\n"); print(str_repeat('=', 80) . "\n");
var_dump($output); var_dump($output);
*/ */
if (preg_match("/^$wanted_re\$/s", $output)) { if (preg_match("/^$wanted_re\$/s", $output)) {
@unlink($tmp_file); @unlink($tmp_file);
show_result("PASS", $tested, $file); show_result("PASS", $tested, $file);
if (isset($old_php)) { if (isset($old_php)) {
$php = $old_php; $php = $old_php;
}
return 'PASSED';
} }
return 'PASSED';
}
} else { } else {
$wanted = trim($section_text['EXPECT']); $wanted = trim($section_text['EXPECT']);
$wanted = preg_replace('/\r\n/',"\n",$wanted); $wanted = preg_replace('/\r\n/',"\n",$wanted);
// compare and leave on success // compare and leave on success
$ok = (0 == strcmp($output,$wanted)); $ok = (0 == strcmp($output,$wanted));
if ($ok) { if ($ok) {
@unlink($tmp_file); @unlink($tmp_file);
show_result("PASS", $tested, $file); show_result("PASS", $tested, $file);
if (isset($old_php)) { if (isset($old_php)) {
$php = $old_php; $php = $old_php;
}
return 'PASSED';
} }
return 'PASSED'; $wanted_re = NULL;
} }
$wanted_re = NULL;
}
} //end of non-valgrind testing } //end of non-valgrind testing