sprintf
This commit is contained in:
parent
9b8983d355
commit
5f9df53708
|
@ -551,10 +551,8 @@ Tput.prototype._compile = function(val) {
|
|||
// as in printf, flags are [-+#] and space. Use a `:' to allow the
|
||||
// next character to be a `-' flag, avoiding interpreting "%-" as an
|
||||
// operator.
|
||||
// if (read(/^%(:-|[+# ])?(\d+(?:\.\d+)?)?([doxXs])/)) {
|
||||
if (read(/^%((?::-|[+# ]){1,4})?(\d+(?:\.\d+)?)?([doxXs])/)) {
|
||||
// echo('sprintf("'+ cap[0].replace(':-', '-') + '", stack.pop())');
|
||||
// var flag = cap[1], width = cap[2], type = cap[3];
|
||||
echo('stack.pop()');
|
||||
continue;
|
||||
}
|
||||
|
@ -562,7 +560,8 @@ Tput.prototype._compile = function(val) {
|
|||
// %c print pop() like %c in printf
|
||||
if (read(/^%c/)) {
|
||||
// echo('sprintf("%c", stack.pop())');
|
||||
echo('stack.pop()');
|
||||
// echo('stack.pop()');
|
||||
echo('String.fromCharCode(stack.pop())');
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -772,6 +771,7 @@ Tput.prototype._compile = function(val) {
|
|||
|
||||
try {
|
||||
return new Function('params', code);
|
||||
// return new Function('sprintf, params', code).bind(null, sprintf);
|
||||
} catch (e) {
|
||||
e.stack = e.stack.replace(/\x1b/g, '\\x1b');
|
||||
throw e;
|
||||
|
|
Loading…
Reference in New Issue