diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-05-21 14:21:52 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-05-21 14:21:52 -0700 |
commit | 62b07e91298336aefb3380f7e707d4f46865797d (patch) | |
tree | fdf4914ada2c142a0109010519c1d9cd827c2123 /src/library.js | |
parent | 7a0ae20872841e0f3a242fba33cb18e65b95b14e (diff) | |
parent | 179dfed363127088299179f252b88e8abc3ff3be (diff) |
Merge branch 'incoming' of github.com:hyperlogic/emscripten into incoming
Diffstat (limited to 'src/library.js')
-rw-r--r-- | src/library.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/library.js b/src/library.js index 2efb7a6f..e79caa4c 100644 --- a/src/library.js +++ b/src/library.js @@ -3576,14 +3576,14 @@ LibraryManager.library = { return -1; }, fscanf__deps: ['$FS', '__setErrNo', '$ERRNO_CODES', - '_scanString', 'getc', 'ungetc'], + '_scanString', 'fgetc', 'fseek', 'ftell'], fscanf: function(stream, format, varargs) { // int fscanf(FILE *restrict stream, const char *restrict format, ... ); // http://pubs.opengroup.org/onlinepubs/000095399/functions/scanf.html if (FS.streams[stream]) { - var stack = []; - var get = function() { var ret = _fgetc(stream); stack.push(ret); return ret }; - var unget = function(c) { return _ungetc(stack.pop(), stream) }; + var i = _ftell(stream), SEEK_SET = 0; + var get = function () { i++; return _fgetc(stream); }; + var unget = function () { _fseek(stream, --i, SEEK_SET); }; return __scanString(format, get, unget, varargs); } else { return -1; |