parent
af1ad01b99
commit
1684a267dc
23
lib/tput.js
23
lib/tput.js
|
@ -636,16 +636,32 @@ Tput.prototype._compile = function(val) {
|
|||
// next character to be a `-' flag, avoiding interpreting "%-" as an
|
||||
// operator.
|
||||
if (read(/^%((?::-|[+# ]){1,4})?(\d+(?:\.\d+)?)?([doxXs])/)) {
|
||||
echo('sprintf("'+ cap[0].replace(':-', '-') + '", stack.pop())');
|
||||
// echo('sprintf("'+ cap[0].replace(':-', '-') + '", stack.pop())');
|
||||
echo('stack.pop()');
|
||||
continue;
|
||||
}
|
||||
|
||||
// %c print pop() like %c in printf
|
||||
if (read(/^%c/)) {
|
||||
echo('sprintf("%c", stack.pop())');
|
||||
// echo('sprintf("%c", stack.pop())');
|
||||
// echo('stack.pop()');
|
||||
echo('String.fromCharCode(stack.pop())');
|
||||
continue;
|
||||
}
|
||||
|
||||
// %d print pop()
|
||||
// "Print (e.g., "%d") is a special case."
|
||||
//if (read(/^%d/)) {
|
||||
// echo('stack.pop()');
|
||||
// continue;
|
||||
//}
|
||||
|
||||
// %s print pop() like %s in printf
|
||||
//if (read(/^%s/)) {
|
||||
// echo('stack.pop()');
|
||||
// continue;
|
||||
//}
|
||||
|
||||
// %p[1-9]
|
||||
// push i'th parameter
|
||||
if (read(/^%p([1-9])/)) {
|
||||
|
@ -841,7 +857,8 @@ Tput.prototype._compile = function(val) {
|
|||
}
|
||||
|
||||
try {
|
||||
return new Function('sprintf, params', code).bind(null, sprintf);
|
||||
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