Revision: 287
http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=287&view=rev
Author: matthiasmiller
Date: 2009-10-22 15:39:55 +0000 (Thu, 22 Oct 2009)
Log Message:
-----------
www: indicate correct error position when the file contains tabs
Modified Paths:
--------------
trunk/www/_jsl_online.inc
Modified: trunk/www/_jsl_online.inc
===================================================================
--- trunk/www/_jsl_online.inc 2009-10-22 13:34:10 UTC (rev 286)
+++ trunk/www/_jsl_online.inc 2009-10-22 15:39:55 UTC (rev 287)
@@ -147,6 +147,11 @@
return $enc;
}
+ function expandTabs($text)
+ {
+ return str_replace("\t", str_pad("", 4/*tab width*/, " "), $text);
+ }
+
function OutputLintHTML($engine)
{
?>
@@ -184,7 +189,7 @@
{
/* format code */
$text = $engine->getLineText($lineno);
- $text = str_replace("\t", str_pad("", 4/*tab width*/, " "), $text);
+ $text = expandTabs($text);
echo getEncodedText(str_pad($lineno+1, $widthOfLineNo, " ", STR_PAD_LEFT) . ' ' . $text . "\n");
/* show errors */
@@ -201,7 +206,13 @@
/* point to the error position, if available */
if ($Error->getChar() > -1)
- echo getEncodedText($lineNoSpacer . str_pad("", $Error->getChar()-1, "=") . "^\n");
+ {
+ $indent = $engine->getLineText($lineno);
+ $indent = substr($indent, 0, max(0, $Error->getChar()-1));
+ $indent = expandTabs($indent);
+ $indent = str_pad("", strlen($indent), "=");
+ echo getEncodedText($lineNoSpacer . $indent . "^\n");
+ }
/* output error type/message */
echo getEncodedText($lineNoSpacer) . '<span>';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|