diff options
-rw-r--r-- | AUTHORS | 6 | ||||
-rw-r--r-- | LICENSE | 8 | ||||
-rw-r--r-- | src/library.js | 16 | ||||
-rw-r--r-- | src/postamble.js | 6 | ||||
-rw-r--r-- | src/preamble.js | 5 | ||||
-rw-r--r-- | tests/files.cpp | 21 | ||||
-rw-r--r-- | tests/runner.py | 2 |
7 files changed, 47 insertions, 17 deletions
@@ -1,2 +1,6 @@ -Alon Zakai <azakai@mozilla.com> +The following authors have all licensed their contributions to Emscripten +under the licensing terms detailed in LICENSE. + +* Alon Zakai <alonzakai@gmail.com> (copyright owned by Mozilla Foundation) +* Tim Dawborn <tim.dawborn@gmail.com> @@ -13,8 +13,7 @@ The full text of both licenses follows. ============================================================================== -Copyright (c) 2010 Alon Zakai -Copyright (c) 2010 Mozilla Foundation +Copyright (c) 2010-2011 Emscripten authors, see AUTHORS file. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -36,12 +35,9 @@ THE SOFTWARE. ============================================================================== -Copyright (c) 2010 Alon Zakai -Copyright (c) 2010 Mozilla Foundation +Copyright (c) 2010-2011 Emscripten authors, see AUTHORS file. All rights reserved. -Developed by: Alon Zakai, Mozilla - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including diff --git a/src/library.js b/src/library.js index c346dd41..704ba8a5 100644 --- a/src/library.js +++ b/src/library.js @@ -226,7 +226,7 @@ var Library = { }, fileno: function(file) { - return 1; // TODO + return file; }, isatty: function(file) { @@ -274,10 +274,10 @@ var Library = { } _stdout = Pointer_make([0], null, ALLOC_STATIC, 'void*'); - {{{ makeSetValue('_stdout', '0', "STDIO.prepare('<<stdin>>', null, true)", 'i32') }}}; + {{{ makeSetValue('_stdout', '0', "STDIO.prepare('<<stdout>>', null, true)", 'i32') }}}; _stderr = Pointer_make([0], null, ALLOC_STATIC, 'void*'); - {{{ makeSetValue('_stderr', '0', "STDIO.prepare('<<stdin>>', null, true)", 'i32') }}}; + {{{ makeSetValue('_stderr', '0', "STDIO.prepare('<<stderr>>', null, true)", 'i32') }}}; }, cleanFilename: function(filename) { return filename.replace('./', ''); @@ -456,7 +456,6 @@ var Library = { fputs__deps: ['$STDIO', 'fputc'], fputs: function(p, stream) { STDIO.write(stream, p, String_len(p)); - _fputc('\n'.charCodeAt(0), stream); }, fputc__deps: ['$STDIO'], @@ -482,6 +481,11 @@ var Library = { }, ungetc: function(chr, stream) { + var f = STDIO.streams[stream]; + if (!f) + return -1; // EOF + if (!f.interactiveInput) + f.position--; return chr; }, @@ -1199,6 +1203,10 @@ var Library = { return 100; }, + getgid: function() { + return 100; + }, + getpwuid: function(uid) { return 0; // NULL }, diff --git a/src/postamble.js b/src/postamble.js index 98d8f578..9b61c0a7 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -17,7 +17,7 @@ Module.callMain = function callMain(args) { argv.push(0); argv = Pointer_make(argv, null, ALLOC_STATIC, 'i32'); - _main(argc, argv, 0); + return _main(argc, argv, 0); } function run(args) { @@ -29,10 +29,12 @@ function run(args) { __globalConstructor__(); + var ret = null; if (Module['_main']) { - Module.callMain(args); + ret = Module.callMain(args); __shutdownRuntime__(); } + return ret; } Module['run'] = run; diff --git a/src/preamble.js b/src/preamble.js index 8cf87bfd..b5a8930a 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -549,7 +549,7 @@ function jrint(label, obj) { // XXX manual debugging // This processes a JS string into a C-line array of numbers, 0-terminated. // For LLVM-originating strings, see parser.js:parseLLVMString function -function intArrayFromString(stringy) { +function intArrayFromString(stringy, dontAddNull) { var ret = []; var t; var i = 0; @@ -557,7 +557,8 @@ function intArrayFromString(stringy) { ret.push(stringy.charCodeAt(i)); i = i + 1; } - ret.push(0); + if (!dontAddNull) + ret.push(0); return ret; } Module['intArrayFromString'] = intArrayFromString; diff --git a/tests/files.cpp b/tests/files.cpp index 39f9e61a..1167bbdf 100644 --- a/tests/files.cpp +++ b/tests/files.cpp @@ -51,12 +51,31 @@ int main() FILE *other = fopen("test.file", "r"); assert(other); + char otherData[1000]; num = fread(otherData, 1, 9, other); otherData[num] = 0; - fclose(other); printf("other=%s.\n", otherData); + // Seeking + + fseek(other, 2, SEEK_SET); + num = fread(otherData, 1, 5, other); + otherData[num] = 0; + printf("seeked=%s.\n", otherData); + + fseek(other, -1, SEEK_CUR); + num = fread(otherData, 1, 3, other); + otherData[num] = 0; + printf("seeked=%s.\n", otherData); + + fseek(other, -2, SEEK_END); + num = fread(otherData, 1, 2, other); + otherData[num] = 0; + printf("seeked=%s.\n", otherData); + + fclose(other); + return 0; } diff --git a/tests/runner.py b/tests/runner.py index 80503de6..8a1fd974 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -1781,7 +1781,7 @@ if 'benchmark' not in sys.argv: other.close() src = open(path_from_root('tests', 'files.cpp'), 'r').read() - self.do_test(src, 'size: 7\ndata: 100,-56,50,25,10,77,123\ninput:hi there!\ntexto\ntexte\n5 : 10,30,20,11,88\nother=some data.\n', post_build=post) + self.do_test(src, 'size: 7\ndata: 100,-56,50,25,10,77,123\ninput:hi there!\ntexto\ntexte\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.', post_build=post) ### 'Big' tests |