aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-01-31 10:59:40 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-01-31 10:59:40 -0800
commit5c35062c0096625f4d7004e243164de79388bedd (patch)
treeac0d606d3ef0c6a66d45866240086f4275182d4e
parent35ef551f44c778fcf1eec7edd7a8afeaf3cead1e (diff)
further fix for #1407
-rw-r--r--src/library.js1
-rw-r--r--tests/core/test_sscanf_6.in14
-rw-r--r--tests/core/test_sscanf_6.out1
-rw-r--r--tests/test_core.py1
4 files changed, 16 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js
index 30453137..632df975 100644
--- a/src/library.js
+++ b/src/library.js
@@ -1642,6 +1642,7 @@ LibraryManager.library = {
next = get();
{{{ makeSetValue('argPtr++', 0, 'next', 'i8') }}};
}
+ if (next === 0) return fields-1; // we failed to read this field
formatIndex += nextC - formatIndex + 1;
continue;
}
diff --git a/tests/core/test_sscanf_6.in b/tests/core/test_sscanf_6.in
index 63ede53f..e0541670 100644
--- a/tests/core/test_sscanf_6.in
+++ b/tests/core/test_sscanf_6.in
@@ -11,4 +11,18 @@ int main() {
i = sscanf(date, "%d.%d.%3c", &d, &m, c);
printf("date: %s; day %2d, month %2d, year %4d, extra: %s, %d\n", date, d, m,
y, c, i);
+
+ {
+ char *date = "18.07.2013", c;
+ int y, m, d, i;
+ if ((i = sscanf(date, "%d.%d.%4d%c", &d, &m, &y, &c)) == 3)
+ {
+ printf("date: %s; day %2d, month %2d, year %4d \n", date, d, m, y);
+ }
+ else
+ {
+ printf("Error in sscanf: actually parsed %d", i);
+ }
+ }
}
+
diff --git a/tests/core/test_sscanf_6.out b/tests/core/test_sscanf_6.out
index 4aee073e..7256b03b 100644
--- a/tests/core/test_sscanf_6.out
+++ b/tests/core/test_sscanf_6.out
@@ -1,2 +1,3 @@
date: 18.07.2013w; day 18, month 7, year 2013, extra: w, 4
date: 18.07.2013w; day 18, month 7, year 2013, extra: 201, 3
+date: 18.07.2013; day 18, month 7, year 2013
diff --git a/tests/test_core.py b/tests/test_core.py
index 594350fb..90453ae2 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -3853,7 +3853,6 @@ Pass: 0.000012 0.000012''')
def test_sscanf_6(self):
test_path = path_from_root('tests', 'core', 'test_sscanf_6')
src, output = (test_path + s for s in ('.in', '.out'))
-
self.do_run_from_file(src, output)
def test_sscanf_skip(self):