diff options
author | alon@honor <none@none> | 2010-09-23 20:21:03 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-09-23 20:21:03 -0700 |
commit | de2a556fcd00d772b112b0105eee7e74f4c1d7b7 (patch) | |
tree | df7efd36872f8d7e9ef85dc06d823140868e4614 /src/snippets.js | |
parent | 1dd1b85c8462a76388686b4fdeb4ec15f420a30a (diff) |
proper print buffering, + cleanup
Diffstat (limited to 'src/snippets.js')
-rw-r--r-- | src/snippets.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/snippets.js b/src/snippets.js index ddcb6d37..ec29f371 100644 --- a/src/snippets.js +++ b/src/snippets.js @@ -1,4 +1,20 @@ var Snippets = { + // stdio.h + + printf: function() { + __print__(Pointer_stringify(__formatString.apply(null, arguments))); + }, + + puts: function(p) { + __print__(Pointer_stringify(p) + '\n'); + }, + + putchar: function(p) { + __print__(String.fromCharCode(p)); + }, + + // ? + vsnprintf: function(dst, num, src, ptr) { var args = Array_copy(ptr+1, HEAP[ptr]); // # of args in in first place var text = __formatString.apply(null, [src].concat(args)); @@ -12,6 +28,14 @@ var Snippets = { __ATEXIT__.push(func); }, + // string.h + + strlen: function(p) { + var q = p; + while (HEAP[q] != 0) q++; + return q - p; + }, + strspn: function(pstr, pset) { var str = String_copy(pstr, true); var set = String_copy(pset); @@ -119,4 +143,5 @@ var Snippets = { Snippets.__cxa_atexit = Snippets.atexit; // iostream Snippets._ZNSolsEi = Snippets._ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc = Snippets._ZNSolsEd = Snippets._ZNSolsEPFRSoS_E = function(stream, data) { print(data) }; +Snippets._ZNSt8ios_base4InitD1Ev = Snippets._ZNSt8ios_base4InitC1Ev; |