aboutsummaryrefslogtreecommitdiff
path: root/src/library.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/library.js')
-rw-r--r--src/library.js30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/library.js b/src/library.js
index b2823fb6..ed7bfa4d 100644
--- a/src/library.js
+++ b/src/library.js
@@ -2560,15 +2560,27 @@ LibraryManager.library = {
continue;
}
- // TODO: Support strings like "%5c" etc.
- if (format[formatIndex] === '%' && format[formatIndex+1] == 'c') {
- var argPtr = {{{ makeGetValue('varargs', 'argIndex', 'void*') }}};
- argIndex += Runtime.getAlignSize('void*', null, true);
- fields++;
- next = get();
- {{{ makeSetValue('argPtr', 0, 'next', 'i8') }}}
- formatIndex += 2;
- continue;
+ if (format[formatIndex] === '%') {
+ var nextC = format.indexOf('c', formatIndex+1);
+ if (nextC > 0) {
+ var maxx = 1;
+ if (nextC > formatIndex+1) {
+ var sub = format.substring(formatIndex+1, nextC)
+ maxx = parseInt(sub);
+ if (maxx != sub) maxx = 0;
+ }
+ if (maxx) {
+ var argPtr = HEAP32[(varargs + argIndex)>>2];
+ argIndex += Runtime.getAlignSize('void*', null, true);
+ fields++;
+ for (var i = 0; i < maxx; i++) {
+ next = get();
+ {{{ makeSetValue('argPtr++', 0, 'next', 'i8') }}};
+ }
+ formatIndex += nextC - formatIndex + 1;
+ continue;
+ }
+ }
}
// remove whitespace