diff options
-rw-r--r-- | AUTHORS | 3 | ||||
-rw-r--r-- | src/library.js | 6 | ||||
-rwxr-xr-x | tests/runner.py | 34 | ||||
-rw-r--r-- | tools/shared.py | 3 |
4 files changed, 44 insertions, 2 deletions
@@ -72,5 +72,4 @@ a license to everyone to use it as detailed in LICENSE.) * Robert Bragg <robert.bragg@intel.com> (copyright owned by Intel Corporation) * Sylvestre Ledru <sylvestre@debian.org> * Tom Fairfield <fairfield@cs.xu.edu> - - +* Anthony J. Thibault <ajt@hyperlogic.org> diff --git a/src/library.js b/src/library.js index cfe83c6e..41796551 100644 --- a/src/library.js +++ b/src/library.js @@ -2465,9 +2465,15 @@ LibraryManager.library = { __scanString.whiteSpace[{{{ charCode(' ') }}}] = 1; __scanString.whiteSpace[{{{ charCode('\t') }}}] = 1; __scanString.whiteSpace[{{{ charCode('\n') }}}] = 1; + __scanString.whiteSpace[{{{ charCode('\v') }}}] = 1; + __scanString.whiteSpace[{{{ charCode('\f') }}}] = 1; + __scanString.whiteSpace[{{{ charCode('\r') }}}] = 1; __scanString.whiteSpace[' '] = 1; __scanString.whiteSpace['\t'] = 1; __scanString.whiteSpace['\n'] = 1; + __scanString.whiteSpace['\v'] = 1; + __scanString.whiteSpace['\f'] = 1; + __scanString.whiteSpace['\r'] = 1; } // Supports %x, %4x, %d.%d, %lld, %s, %f, %lf. // TODO: Support all format specifiers. diff --git a/tests/runner.py b/tests/runner.py index 8e3b3e0d..d9780696 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -6041,6 +6041,40 @@ Pass: 0.000012 0.000012''') ''' self.do_run(src, '''0:173,16 1:16,173 2:183,173 3:17,287 4:98,123''') + def test_sscanf_other_whitespace(self): + Settings.SAFE_HEAP = 0 # use i16s in printf + + src = r''' + #include<stdio.h> + + int main() { + short int x; + short int y; + + const char* buffer[] = { + "\t2\t3\t", /* TAB - horizontal tab */ + "\t\t5\t\t7\t\t", + "\n11\n13\n", /* LF - line feed */ + "\n\n17\n\n19\n\n", + "\v23\v29\v", /* VT - vertical tab */ + "\v\v31\v\v37\v\v", + "\f41\f43\f", /* FF - form feed */ + "\f\f47\f\f53\f\f", + "\r59\r61\r", /* CR - carrage return */ + "\r\r67\r\r71\r\r" + }; + + for (int i=0; i<10; ++i) { + x = 0; y = 0; + sscanf(buffer[i], " %d %d ", &x, &y); + printf("%d, %d, ", x, y); + } + + return 0; + } + ''' + self.do_run(src, '''2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, ''') + def test_sscanf_3(self): # i64 if not Settings.USE_TYPED_ARRAYS == 2: return self.skip('64-bit sscanf only supported in ta2') diff --git a/tools/shared.py b/tools/shared.py index 5a9860db..0818f6b9 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -509,6 +509,9 @@ COMPILER_OPTS = COMPILER_OPTS + ['-m32', '-U__i386__', '-U__i386', '-Ui386', '-D__IEEE_LITTLE_ENDIAN', '-fno-math-errno', '-fno-threadsafe-statics', '-target', LLVM_TARGET] +if LLVM_TARGET == 'le32-unknown-nacl': + COMPILER_OPTS += ['-U__native_client__', '-U__pnacl__', '-U__ELF__'] # The nacl target is originally used for Google Native Client. Emscripten is not NaCl, so remove the platform #define, when using their triple. + USE_EMSDK = not os.environ.get('EMMAKEN_NO_SDK') if USE_EMSDK: |