Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes to IO stubs #26

Merged
merged 5 commits into from
Jun 24, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ The following authors have all licensed their contributions to Emscripten
under the licensing terms detailed in LICENSE.

* Alon Zakai <[email protected]> (copyright owned by Mozilla Foundation)
*
*
* Tim Dawborn <[email protected]>

16 changes: 12 additions & 4 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ var Library = {
},

fileno: function(file) {
return 1; // TODO
return file;
},

isatty: function(file) {
Expand Down Expand Up @@ -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('./', '');
Expand Down Expand Up @@ -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'],
Expand All @@ -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;
},

Expand Down Expand Up @@ -1199,6 +1203,10 @@ var Library = {
return 100;
},

getgid: function() {
return 100;
},

getpwuid: function(uid) {
return 0; // NULL
},
Expand Down
6 changes: 4 additions & 2 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,15 +549,16 @@ 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;
while (i < stringy.length) {
ret.push(stringy.charCodeAt(i));
i = i + 1;
}
ret.push(0);
if (!dontAddNull)
ret.push(0);
return ret;
}
Module['intArrayFromString'] = intArrayFromString;
Expand Down