diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-08-30 11:21:48 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-08-30 11:21:48 -0700 |
commit | b5b49215d4a40566380a769f47a9c1cce74a28b0 (patch) | |
tree | 68308b6059798a81f24f6a8a1ac28a0091c5d066 /src/library.js | |
parent | 1cc28b8e9e94267041bc71afebfbbe3059db4a3f (diff) | |
parent | b895cdc7df2085d324003c9df582a3dcc1927697 (diff) |
Merge branch 'incoming'
Diffstat (limited to 'src/library.js')
-rw-r--r-- | src/library.js | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js index 3ba2f56b..f6b3d5ef 100644 --- a/src/library.js +++ b/src/library.js @@ -2261,7 +2261,11 @@ LibraryManager.library = { // void clearerr(FILE *stream); // http://pubs.opengroup.org/onlinepubs/000095399/functions/clearerr.html stream = FS.getStream(stream); - if (stream) stream.error = false; + if (!stream) { + return; + } + stream.eof = false; + stream.error = false; }, fclose__deps: ['close', 'fsync'], fclose: function(stream) { @@ -2322,7 +2326,6 @@ LibraryManager.library = { if (streamObj.eof || streamObj.error) return -1; var ret = _fread(_fgetc.ret, 1, 1, stream); if (ret == 0) { - streamObj.eof = true; return -1; } else if (ret == -1) { streamObj.error = true; @@ -5154,6 +5157,37 @@ LibraryManager.library = { }, // ========================================================================== + // termios.h + // ========================================================================== + tcgetattr: function(fildes, termios_p) { + // http://pubs.opengroup.org/onlinepubs/009695399/functions/tcgetattr.html + var stream = FS.getStream(fildes); + if (!stream) { + ___setErrNo(ERRNO_CODES.EBADF); + return -1; + } + if (!stream.tty) { + ___setErrNo(ERRNO_CODES.ENOTTY); + return -1; + } + return 0; + }, + + tcsetattr: function(fildes, optional_actions, termios_p) { + // http://pubs.opengroup.org/onlinepubs/7908799/xsh/tcsetattr.html + var stream = FS.getStream(fildes); + if (!stream) { + ___setErrNo(ERRNO_CODES.EBADF); + return -1; + } + if (!stream.tty) { + ___setErrNo(ERRNO_CODES.ENOTTY); + return -1; + } + return 0; + }, + + // ========================================================================== // time.h // ========================================================================== |