diff options
-rw-r--r-- | AUTHORS | 4 | ||||
-rw-r--r-- | src/library.js | 6 | ||||
-rwxr-xr-x | tests/runner.py | 20 |
3 files changed, 22 insertions, 8 deletions
@@ -46,3 +46,7 @@ a license to everyone to use it as detailed in LICENSE.) * Anthony Liot <wolfviking0@yahoo.com> * Michael Riss <Michael.Riss@gmx.de> * Jasper St. Pierre <jstpierre@mecheye.net> +* Manuel Schölling <manuel.schoelling@gmx.de> + + + diff --git a/src/library.js b/src/library.js index f55b7893..9268edd5 100644 --- a/src/library.js +++ b/src/library.js @@ -2515,7 +2515,7 @@ LibraryManager.library = { var curr = 0; var buffer = []; // Read characters according to the format. floats are trickier, they may be in an unfloat state in the middle, then be a valid float later - if (type == 'f') { + if (type == 'f' || type == 'e' || type == 'g' || type == 'E') { var last = 0; next = get(); while (next > 0) { @@ -2569,6 +2569,10 @@ LibraryManager.library = { {{{ makeSetValue('argPtr', 0, 'parseInt(text, 16)', 'i32') }}} break; case 'f': + case 'e': + case 'g': + case 'E': + // fallthrough intended if (long_) { {{{ makeSetValue('argPtr', 0, 'parseFloat(text)', 'double') }}} } else { diff --git a/tests/runner.py b/tests/runner.py index 3a7f1565..a33bf133 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4920,13 +4920,19 @@ at function.:blag printf("%f, %f\n", atof("1.234567"), atof("cheez")); - float n = -1; - sscanf(" 2.8208", "%f", &n); - printf("%.4f\n", n); + char float_formats[] = "fegE"; + char format[] = "%_"; + for(int i = 0; i < 4; ++i) { + format[1] = float_formats[i]; - float a = -1; - sscanf("-3.03", "%f", &a); - printf("%.4f\n", a); + float n = -1; + sscanf(" 2.8208", format, &n); + printf("%.4f\n", n); + + float a = -1; + sscanf("-3.03", format, &a); + printf("%.4f\n", a); + } char buffy[100]; sscanf("cheez some thing moar 123\nyet more\n", "cheez %s", buffy); @@ -4959,7 +4965,7 @@ at function.:blag return 0; } ''' - self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n2.8208\n-3.0300\n|some|\n|something|\n|somethingmoar|\n' + + self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n2.8208\n-3.0300\n2.8208\n-3.0300\n2.8208\n-3.0300\n2.8208\n-3.0300\n|some|\n|something|\n|somethingmoar|\n' + '1\n1499\n' + '5\n87,0.481565,0.059481,0,1\n' + '3\n-123,4294966531,-34\n' + |