diff options
Diffstat (limited to 'libsm/t-qic.c')
-rw-r--r-- | libsm/t-qic.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/libsm/t-qic.c b/libsm/t-qic.c index 11375750a196..fea88c95b43d 100644 --- a/libsm/t-qic.c +++ b/libsm/t-qic.c @@ -44,14 +44,15 @@ show_diff(s1, s2) } } -char *quote_unquote __P((char *, char *, int, int)); +char *quote_unquote __P((char *, char *, int, int, int)); char * -quote_unquote(in, out, outlen, exp) +quote_unquote(in, out, outlen, exp, mode) char *in; char *out; int outlen; int exp; + int mode; { char *obp, *bp; char line_back[1024]; @@ -59,9 +60,14 @@ quote_unquote(in, out, outlen, exp) int cmp; sm_strlcpy(line_in, in, sizeof(line_in)); - obp = quote_internal_chars(in, out, &outlen); + obp = quote_internal_chars(in, out, &outlen, NULL); bp = str2prt(line_in); - dequote_internal_chars(obp, line_back, sizeof(line_back)); + if (0 == mode) + dequote_internal_chars(obp, line_back, sizeof(line_back)); + else if (1 == mode) + dequote_internal_chars(obp, line_back, strlen(obp)); + else if (2 == mode) + dequote_internal_chars(obp, line_back, strlen(obp) + 1); cmp = strcmp(line_in, line_back); SM_TEST(exp == cmp); if (cmp != exp && !SmTestVerbose) @@ -98,11 +104,13 @@ main(argc, argv) char *argv[]; { char line_in[1024], line[256], line_out[32], *obp; - int i, los, cmp; + int i, los, cmp, mode; sm_qic_T inout[] = { { "", "", 0 } , { "abcdef", "abcdef", 0 } , { "01234567890123456789", "01234567890123456789", 0 } + , { "\\", "\\", 0 } + , { "\\A", "\\A", 0 } , { "01234567890123456789\001", "01234567890123456789\001", 0 } , { "012345\2067890123456789", "012345\377\2067890123456789", @@ -121,6 +129,9 @@ main(argc, argv) }; sm_test_begin(argc, argv, "test meta quoting"); + mode = 0; + if (argc > 1) + mode = atoi(argv[1]); for (i = 0; i < sizeof(line_out); i++) line_out[i] = '\0'; for (i = 0; i < sizeof(line_in); i++) @@ -135,7 +146,7 @@ main(argc, argv) line_in[i] = ch; } los = sizeof(line_out) / 2; - obp = quote_unquote(line_in, line_out, los, 0); + obp = quote_unquote(line_in, line_out, los, 0, mode); if (obp != line_out) SM_FREE(obp); @@ -151,7 +162,7 @@ main(argc, argv) line_in[i] = ch; } los = sizeof(line_in); - obp = quote_unquote(line_in, line_in, los, 0); + obp = quote_unquote(line_in, line_in, los, 0, mode); if (obp != line_in) SM_FREE(obp); @@ -159,7 +170,7 @@ main(argc, argv) { los = sizeof(line_out) / 2; obp = quote_unquote(inout[i].qic_in, line_out, los, - inout[i].qic_exp); + inout[i].qic_exp, mode); cmp = strcmp(inout[i].qic_out, obp); SM_TEST(inout[i].qic_exp == cmp); if (inout[i].qic_exp != cmp && !SmTestVerbose) @@ -186,7 +197,7 @@ main(argc, argv) los = sm_strlcpy(line, inout[i].qic_in, sizeof(line)); SM_TEST(los + 1 < sizeof(line)); ++los; - obp = quote_unquote(line, line, los, inout[i].qic_exp); + obp = quote_unquote(line, line, los, inout[i].qic_exp, mode); cmp = strcmp(inout[i].qic_out, obp); SM_TEST(inout[i].qic_exp == cmp); if (inout[i].qic_exp != cmp && !SmTestVerbose) @@ -214,7 +225,7 @@ main(argc, argv) { los = 0; obp = quote_unquote(inout[i].qic_in, NULL, los, - inout[i].qic_exp); + inout[i].qic_exp, mode); SM_TEST(obp != NULL); cmp = strcmp(inout[i].qic_out, obp); SM_TEST(inout[i].qic_exp == cmp); |