[xml] Incorrect linenumber in error reporting



Hello,

When parsing an XML file containing a comment with an empty line, libxml reports the wrong line number for errors occurring after the comment. This only happens with libxml compiled for Windows and files saved in Windows format (with CR+LF line endings), so I guess somewhere both CR and LF are counted as separate line endings.

Examples:

The document:
<!--
-->

gives the following correct xmllint output, with an error on line 2:
file:///z:/tests/linenum.xml:2: parser error : Start tag expected, '<' not found
-->
  ^

When I add an empty line to the comment:
<!--

-->

xmllint says the error occurs on line 4 instead of line 3:
file:///z:/tests/linenum.xml:4: parser error : Start tag expected, '<' not found
-->
  ^

But adding another empty line increases the line count with just 1:
<!--


-->

produces the following error on line 5:
file:///z:/tests/linenum.xml:5: parser error : Start tag expected, '<' not found
-->
  ^

So if a Windows-formatted XML document contains a comment with one or more empty lines, the line number is one too high. For Unix-formatted documents, the line count is correct. I have tested this with libxml version 2.7.3 for Windows (as compiled by Igor Zlatovic). I also ran xmllint on a Unix system which reported the correct line numbers, but that was only version 2.6.20.

Kris Breuker



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]