diff options
author | George Kadianakis <desnacked@riseup.net> | 2012-04-03 16:20:24 +0200 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2012-04-03 16:20:24 +0200 |
commit | b80728a115213abfaab6b3a124caac617ce5d253 (patch) | |
tree | 2c34856933d9c53e9c6d1f2895f741baf90d0485 /src/test/test_util.c | |
parent | 42143979d8c594525583ea8de15abf18636f78b1 (diff) | |
download | tor-b80728a115213abfaab6b3a124caac617ce5d253.tar.gz tor-b80728a115213abfaab6b3a124caac617ce5d253.zip |
tor_vsscanf(): Don't return -1 if '%%' doesn't match.
tor_vsscanf() is supposed to return the current number of matches on
match failure.
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 88f00e071b..f2123c5540 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -1384,7 +1384,6 @@ test_util_sscanf(void) test_eq(-1, tor_sscanf("wrong", "%5c", s1)); /* %c cannot have a number. */ test_eq(-1, tor_sscanf("hello", "%s", s1)); /* %s needs a number. */ test_eq(-1, tor_sscanf("prettylongstring", "%999999s", s1)); - test_eq(-1, tor_sscanf("We're the 99 monkeys", "We're the 99%%")); #if 0 /* GCC thinks these two are illegal. */ test_eq(-1, tor_sscanf("prettylongstring", "%0s", s1)); @@ -1468,6 +1467,11 @@ test_util_sscanf(void) /* Literal '%' (ie. '%%') */ test_eq(1, tor_sscanf("99% fresh", "%3u%% fresh", &u1)); test_eq(99, u1); + test_eq(0, tor_sscanf("99 fresh", "%% %3u %s", &u1, s1)); + test_eq(1, tor_sscanf("99 fresh", "%3u%% %s", &u1, s1)); + test_eq(2, tor_sscanf("99 fresh", "%3u %5s %%", &u1, s1)); + test_eq(99, u1); + test_streq(s1, "fresh"); test_eq(1, tor_sscanf("% boo", "%% %3s", s1)); test_streq("boo", s1); |