diff options
-rw-r--r-- | src/library.js | 13 | ||||
-rw-r--r-- | tests/runner.py | 12 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/library.js b/src/library.js index 23a63481..634f98dc 100644 --- a/src/library.js +++ b/src/library.js @@ -3575,15 +3575,22 @@ LibraryManager.library = { return pdest; }, - strtol: function(ptr) { - assert(!arguments[1] && !arguments[2], "We don't support all strtol params yet"); - return parseInt(Pointer_stringify(ptr)); + strtol: function(ptr, endptr, base) { + assert(!endptr, "We don't support all strtol params yet"); + return parseInt(Pointer_stringify(ptr), base); + }, + strtoul__deps: ['strtol'], + strtoul: function(ptr, endptr, base) { + var result = _strtol(ptr, endptr, base); + return unSign(result, 32); }, strcmp__deps: ['strncmp'], strcmp: function(px, py) { return _strncmp(px, py, TOTAL_MEMORY); }, + // We always assume ASCII locale. + strcoll: 'strcmp', strcasecmp__deps: ['strncasecmp'], strcasecmp: function(px, py) { diff --git a/tests/runner.py b/tests/runner.py index e866649d..438726af 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -1623,10 +1623,20 @@ if 'benchmark' not in sys.argv: printf("*%.1f*\\n", strtod("66", NULL)); // checks dependency system, as our strtod needs _isspace etc. + printf("*%ld*\\n", strtol("10", NULL, 0)); + printf("*%ld*\\n", strtol("0", NULL, 0)); + printf("*%ld*\\n", strtol("-10", NULL, 0)); + printf("*%ld*\\n", strtol("12", NULL, 16)); + + printf("*%lu*\\n", strtoul("10", NULL, 0)); + printf("*%lu*\\n", strtoul("0", NULL, 0)); + printf("*%lu*\\n", strtoul("-10", NULL, 0)); + return 0; } ''' - self.do_test(src, '*1,2,3,5,5,6*\n*stdin==0:0*\n*%*\n*5*\n*66.0*\n*cleaned*') + + self.do_test(src, '*1,2,3,5,5,6*\n*stdin==0:0*\n*%*\n*5*\n*66.0*\n*10*\n*0*\n*-10*\n*18*\n*10*\n*0*\n*4294967286*\n*cleaned*') def test_time(self): src = open(path_from_root('tests', 'time', 'src.c'), 'r').read() |