fprintf (stderr, "$ %s 2 <regex> <string>\n", progname);
}
+/* Quick-and-dirty thing to correct backslashes in C code: */
+string escape_str(string n) {
+ string foo("");
+ for (string::iterator it = n.begin(); it != n.end(); it++) {
+ if (*it == '\\') foo += "\\\\";
+ else foo += *it;
+ }
+ return foo;
+}
+
int main(int argc, char *argv [])
{
if (argc < 2)
translator_output o(cout);
string t(argv[3]);
- string match_expr = "\"" + t + "\""; // TODOXXX escape argv[3]
+ string match_expr = "\"" + escape_str(t) + "\"";
// emit code skeleton
o.line() << "// test output for systemtap-re2c";
o.indent(1);
o.newline() << "int ans = ";
d.emit_matchop_start (&o);
- o.line() << match_expr; // TODOXXX escape argv[3]
+ o.line() << match_expr;
d.emit_matchop_end (&o);
o.line() << ";";
o.newline() << "printf(\"match %s\\n\", ans ? \"succeed\" : \"fail\");";
} else if (test_type == 0) {
o.newline() << "exit(ans ? 0 : 1);";
}
- /* TODO test type 2 should fail to compile */
+ /* TODOXXX test type 2 should fail to compile */
o.newline(-1) << "}";
o.newline();