aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Guryanov <caiiiycuk@gmail.com>2012-10-28 19:29:00 +0700
committerAleksander Guryanov <caiiiycuk@gmail.com>2012-10-31 21:47:42 +0700
commit192e25b88589bb137fb960de31b3e08de2562991 (patch)
treea04c14cc0363ae2b55a8e0477af58de53d838222 /src
parent4b94e181cb4ff08b26264c34ed6818f5a3fd2225 (diff)
Fix sscanf whitespace bug
Add test for sscanf
Diffstat (limited to 'src')
-rw-r--r--src/library.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/library.js b/src/library.js
index 1cfe309a..4ad6e06a 100644
--- a/src/library.js
+++ b/src/library.js
@@ -2456,19 +2456,22 @@ LibraryManager.library = {
var fields = 0;
var argIndex = 0;
var next;
- // remove initial whitespace
- while (1) {
- next = get();
- if (next == 0) return 0;
- if (!(next in __scanString.whiteSpace)) break;
- }
- unget(next);
+
next = 1;
mainLoop:
for (var formatIndex = 0; formatIndex < format.length; formatIndex++) {
+ // remove whitespace
+ while (1) {
+ next = get();
+ if (next == 0) return fields;
+ if (!(next in __scanString.whiteSpace)) break;
+ }
+ unget(next);
+
if (next <= 0) return fields;
var next = get();
if (next <= 0) return fields; // End of input.
+
if (format[formatIndex] === '%') {
formatIndex++;
var maxSpecifierStart = formatIndex;