diff options
-rw-r--r-- | src/library.js | 6 | ||||
-rwxr-xr-x | tests/runner.py | 9 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/library.js b/src/library.js index 1bb58833..8e38b130 100644 --- a/src/library.js +++ b/src/library.js @@ -2417,8 +2417,8 @@ LibraryManager.library = { while ((curr < max_ || isNaN(max_)) && next > 0) { if (!(next in __scanString.whiteSpace) && // stop on whitespace (type == 's' || - ((type === 'd' || type == 'u') && ((next >= '0'.charCodeAt(0) && next <= '9'.charCodeAt(0)) || - (first && next == '-'.charCodeAt(0)))) || + ((type === 'd' || type == 'u' || type == 'i') && ((next >= '0'.charCodeAt(0) && next <= '9'.charCodeAt(0)) || + (first && next == '-'.charCodeAt(0)))) || (type === 'x' && (next >= '0'.charCodeAt(0) && next <= '9'.charCodeAt(0) || next >= 'a'.charCodeAt(0) && next <= 'f'.charCodeAt(0) || next >= 'A'.charCodeAt(0) && next <= 'F'.charCodeAt(0)))) && @@ -2437,7 +2437,7 @@ LibraryManager.library = { var argPtr = {{{ makeGetValue('varargs', 'argIndex', 'void*') }}}; argIndex += Runtime.getNativeFieldSize('void*'); switch (type) { - case 'd': case 'u': + case 'd': case 'u': case 'i': if (half) { {{{ makeSetValue('argPtr', 0, 'parseInt(text, 10)', 'i16') }}}; } else { diff --git a/tests/runner.py b/tests/runner.py index c61fee3a..8e1eaeba 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4264,13 +4264,20 @@ at function.:blag printf("%d\n", sscanf("-123 -765 -34-6", "%d %u %d", &neg, &neg2, &neg3)); printf("%d,%u,%d\n", neg, neg2, neg3); + { + int a = 0; + sscanf("1", "%i", &a); + printf("%i\n", a); + } + return 0; } ''' self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n2.8208\n-3.0300\n|some|\n|something|\n|somethingmoar|\n' + '1\n1499\n' + '5\n87,0.481565,0.059481,0,1\n' + - '3\n-123,4294966531,-34\n') + '3\n-123,4294966531,-34\n' + + '1\n') def test_sscanf_2(self): # doubles |