diff options
author | Alon Zakai <azakai@mozilla.com> | 2010-12-05 19:13:00 -0800 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2010-12-05 19:13:00 -0800 |
commit | 78b2976bcbbb7e0e36a60bd643adefc1226a09a6 (patch) | |
tree | fde05ecf3aa137d90a8befbbc46305795700b617 /src | |
parent | cb23e4c23c63bf1e6cde5af24028012734731681 (diff) |
library additions
Diffstat (limited to 'src')
-rw-r--r-- | src/library.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/library.js b/src/library.js index b4efd901..6a8e426d 100644 --- a/src/library.js +++ b/src/library.js @@ -300,6 +300,19 @@ var Library = { return 0; }, + strrchr: function(ptr, chr) { + var ptr2 = ptr + Pointer_stringify(ptr).length; // TODO: use strlen, but need dependencies system + do { + if (IHEAP[ptr2] == chr) return ptr2; + ptr2--; + } while (ptr2 >= ptr); + return 0; + }, + + strdup: function(ptr) { + return Pointer_make(String_copy(ptr, true), 0, ALLOC_NORMAL); + }, + // ctype.h isdigit: function(chr) { @@ -338,6 +351,13 @@ var Library = { return chr; }, + tolower: function(chr) { + if (chr >= 'A'.charCodeAt(0) && chr <= 'Z'.charCodeAt(0)) { + return chr - 'A'.charCodeAt(0) + 'a'.charCodeAt(0); + } + return chr; + }, + // ctype.h Linux specifics __ctype_b_loc: function() { // http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/baselib---ctype-b-loc.html @@ -586,10 +606,33 @@ var Library = { return 0; }, + __libc_current_sigrtmin: function() { + return 0; + }, + __libc_current_sigrtmax: function() { + return 0; + }, + // stat.h __01stat64_: function() { return -1 }, __01fstat64_: function() { return -1 }, + + // locale.h + + setlocale: function(category, locale) { + return 0; + }, + + // langinfo.h + + nl_langinfo: function(item) { + var me = arguments.callee; + if (!me.ret) { + me.ret = Pointer_make(intArrayFromString("eh?"), null); + } + return me.ret; + }, }; load('library_sdl.js'); |