diff options
Diffstat (limited to 'src/library.js')
-rw-r--r-- | src/library.js | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/src/library.js b/src/library.js index 59f2f6c6..b45ef8db 100644 --- a/src/library.js +++ b/src/library.js @@ -2133,20 +2133,7 @@ LibraryManager.library = { _exit: function(status) { // void _exit(int status); // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html - - function ExitStatus() { - this.name = "ExitStatus"; - this.message = "Program terminated with exit(" + status + ")"; - this.status = status; - Module.print('Exit Status: ' + status); - }; - ExitStatus.prototype = new Error(); - ExitStatus.prototype.constructor = ExitStatus; - - exitRuntime(); - ABORT = true; - - throw new ExitStatus(); + Module['exit'](status); }, fork__deps: ['__setErrNo', '$ERRNO_CODES'], fork: function() { @@ -3653,29 +3640,19 @@ LibraryManager.library = { ___setErrNo(ERRNO_CODES.EAGAIN); return -1; }, - fscanf__deps: ['$FS', '__setErrNo', '$ERRNO_CODES', - '_scanString', 'fgetc', 'fseek', 'ftell'], + fscanf__deps: ['$FS', '_scanString', 'fgetc', 'ungetc'], 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 i = _ftell(stream), SEEK_SET = 0; - // if the stream does not support seeking backwards (e.g. stdin), buffer it here - var buffer = [], bufferIndex = 0; + var buffer = []; var get = function() { - if (bufferIndex < buffer.length) { - return buffer[bufferIndex++]; - } - i++; - bufferIndex++; var c = _fgetc(stream); buffer.push(c); return c; }; var unget = function() { - if (_fseek(stream, --i, SEEK_SET) !== 0) { - bufferIndex--; - } + _ungetc(buffer.pop(), stream); }; return __scanString(format, get, unget, varargs); } else { @@ -3939,8 +3916,7 @@ LibraryManager.library = { __cxa_atexit: 'atexit', abort: function() { - ABORT = true; - throw 'abort() at ' + (new Error().stack); + Module['abort'](); }, bsearch: function(key, base, num, size, compar) { |