From f1ddce570eec1666144d7fa80c37ed83991d5ec5 Mon Sep 17 00:00:00 2001 From: portix Date: Tue, 26 Feb 2013 01:00:38 +0100 Subject: Curry formatLine in io.debug --- scripts/lib/io.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/lib/io.js b/scripts/lib/io.js index 62988540..33423433 100644 --- a/scripts/lib/io.js +++ b/scripts/lib/io.js @@ -10,7 +10,7 @@ var regHasDwb = new RegExp("[^]*/\\*\\*/[^]*"); var prefixEditor = " "; var prefixHighlight = "--> "; - var formatLine = function(line, max) + var _formatLine = function(max, line) { var size = max - Math.ceil(Math.log(line+1)/Math.log(10)) + 1; return Array(size).join(" ") + line + " > "; @@ -91,7 +91,7 @@ caller = String(this._arguments.callee).replace(regHasDwb, "$1", ""); source = caller.split("\n"); var length = source.length; - var max = Math.ceil(Math.log(source.length+1)/Math.log(10)); + var formatLine = _formatLine.bind(null, Math.ceil(Math.log(source.length+1)/Math.log(10))); outMessage += prefixSource; if (length >= line-2 && line-2 >= 0) @@ -100,15 +100,15 @@ outMessage += prefixEditor + "...\n"; else outMessage += prefixEditor + "BOF\n"; - outMessage += prefixEditor + formatLine(line-1, max) + source[line-2] + "\n"; + outMessage += prefixEditor + formatLine(line-1) + source[line-2] + "\n"; } else - outMessage += prefixEditor + "BOF\n" + outMessage += prefixEditor + "BOF\n"; if (length > line-1) - outMessage += prefixHighlight + formatLine(line, max) + source[line-1] + "\n"; + outMessage += prefixHighlight + formatLine(line) + source[line-1] + "\n"; if (length > line && length != line+1) { - outMessage += prefixEditor + formatLine(line+1, max) + source[line]; + outMessage += prefixEditor + formatLine(line+1) + source[line]; if (length > line + 2) outMessage += "\n" + prefixEditor + "..."; else @@ -127,6 +127,7 @@ outMessage += prefixFunction; } io.print(outMessage + "\n", "stderr"); + return undefined; } } -- cgit v1.2.3