aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-08-27 20:24:02 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-08-27 20:24:02 -0700
commit58a2ec60c63b0179b5fa215af1934fe297356f7d (patch)
tree024ff95c3a9b0c58ac8420f3de42833affabfc9f
parent61079c0fece38f2e797f4eb5ec0376ffedabcd2b (diff)
parentc9f8502174ea45ced66419704e9aa99e5ca62e66 (diff)
Merge pull request #548 from andreabedini/gh-141
Use strto{l,l,ll,d} for ato{i,l,ll,f} repectively (take two)
-rw-r--r--AUTHORS1
-rw-r--r--src/library.js32
2 files changed, 21 insertions, 12 deletions
diff --git a/AUTHORS b/AUTHORS
index 6fc245cf..a5fce188 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -31,3 +31,4 @@ a license to everyone to use it as detailed in LICENSE.)
* YeZhongWen <linghuye2.0@gmail.com>
* Xingxing Pan <forandom@gmail.com>
* Justin Kerk <dopefishjustin@gmail.com>
+* Andrea Bedini <andrea.bedini@gmail.com>
diff --git a/src/library.js b/src/library.js
index dda3e0a5..6a94be40 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;
+ return _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'],