diff options
author | max99x <max99x@gmail.com> | 2011-08-23 08:50:23 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-08-23 08:51:29 +0300 |
commit | dc1e8a0fb689436866d253036090e9fe7d4f3d73 (patch) | |
tree | 6b28e902b69c27e834f6154c3ceef32d5c510006 | |
parent | 0e2cbf14971ff4145c62e61e118fc6095a658a3a (diff) |
Added strcoll() and strtoul() and improved strtol().
-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() |