Re: [Patch] To get a column number relative to the beginning of the line

| Date: Sat, 16 Feb 2002 18:58:32 +0100
| From: Terje Bless <>
| marc bevand <> wrote:
| > I have written a small patch in order to have the real column
| >number of the error displayed.
| Pardon me for being dense, but what problem is this patch trying to solve?
| Are we spitting out the wrong column number on a regular basis?

Well, the problem is that when you have an file containing errors
beyond the 70th colum, the validator will extract 70 chars of the
erroneous line (and will prepend and append "..."), so that the error
is (almost) always located at the 50th column (relative to the
beginning of the 70 extracted chars). So, the error is (almost)
_always_ reported to be located at the 50th column ! I (and probably
lots of other people) would preferrer to get the column number
relative to the beginning of the line in the file, in order, for
example, to jump directly to the right column in my favorite text

By the way, just ignore the previous patch, I just have found a better
way to accomplish what I would:

diff -Nur validator.orig/httpd/cgi-bin/check validator/httpd/cgi-bin/check
--- validator.orig/httpd/cgi-bin/check  Thu Feb 17 01:28:04 2000
+++ validator/httpd/cgi-bin/check       Thu Feb 17 01:29:23 2000
@@ -1325,7 +1325,7 @@
     $line = &ent($line); # Entity encode.
     $line =~s/\t//g;   # Collapse TABs.
-    print qq(  <li>Line <a href="#line-$err->{line}">$err->{line}<>, column $col:\n);
+    print qq(  <li>Line <a href="#line-$err->{line}">$err->{line}<>, column $col [$err->{char} in the file]:\n);
     print "<pre>  <code class=input>$line</code>\n";
     print ""x ($col + 2); # 2 is the number of spaces before <code> above

Marc Bevand.

Received on Saturday, 16 February 2002 19:36:06 UTC