diff options
author | Andrea Bedini <andrea.bedini@gmail.com> | 2012-08-25 14:38:46 +1000 |
---|---|---|
committer | Andrea Bedini <andrea.bedini@gmail.com> | 2012-08-25 14:41:18 +1000 |
commit | c2ce1ae801e43d7a3e5e7b0256a33a6ec28fabb9 (patch) | |
tree | 06eb338c3d43fe1dbd2b063be3e904eb51daaeee | |
parent | 7618310d969295b610805b7240048e7e2a737f36 (diff) |
Use strto{l,l,ll,d} for ato{i,l,ll,d} repectively, as does glibc (see gh-141).
-rw-r--r-- | src/library.js | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/library.js b/src/library.js index cfa29c58..95e0503c 100644 --- a/src/library.js +++ b/src/library.js @@ -3479,16 +3479,6 @@ LibraryManager.library = { abs: 'Math.abs', labs: 'Math.abs', - atoi__deps: ['isspace', 'isdigit'], - atoi: function(s) { - var c; - while ((c = {{{ makeGetValue('s', 0, 'i8') }}}) && _isspace(c)) s++; - if (!c || !_isdigit(c)) return 0; - var e = s; - while ((c = {{{ makeGetValue('e', 0, 'i8') }}}) && _isdigit(c)) e++; - return Math.floor(Number(Pointer_stringify(s).substr(0, e-s))); - }, - exit__deps: ['_exit'], exit: function(status) { __exit(status); @@ -3723,10 +3713,28 @@ LibraryManager.library = { }, strtoull_l: 'strtoull', // no locale support yet + atof__deps: ['strtod'], atof: function(ptr) { var str = Pointer_stringify(ptr); - var ret = parseFloat(str); - return isNaN(ret) ? 0 : ret; + var ret = _strtod(ptr, null); + }, + + atoi__deps: ['strtol'], + atoi: function(ptr) { + var str = Pointer_stringify(ptr); + return _strtol(ptr, null, 10); + }, + + atol__deps: ['strtol'], + atol: function(ptr) { + var str = Pointer_stringify(ptr); + return _strtol(ptr, null, 10); + }, + + atoll__deps: ['strtoll'], + atoll: function(ptr) { + var str = Pointer_stringify(ptr); + return _strtoll(ptr, null, 10); }, qsort__deps: ['memcpy'], |