CRLF handling after a comment
The way of handling CRLF in the input stream looks wrong.
/* gcc test-newline.c `pkg-config --cflags libxml-2.0` `pkg-config --libs libxml-2.0` */
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <stdio.h>
#include <string.h>
#define CRLF "\r\n"
#define __LF " \n"
const char * crlf = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><root><!---->"CRLF CRLF"<target/></root>";
const char * __lf = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><root><!---->"__LF __LF"<target/></root>";
void run(const char *title, const char *input)
{
xmlDocPtr doc = xmlParseMemory(input, strlen(input));
xmlNode *root = xmlDocGetRootElement(doc);
xmlNode *node = root->children->next->next;
printf("%s: tag: %s, line: %u\n", title,
node->name, (unsigned int)node->line);
}
int main(void)
{
xmlLineNumbersDefault (1);
run("crlf", crlf);
run("__lf", __lf);
return 0;
}
This program prints the line number of "target" node in the input.
With libxml-2.0 built from 455c61d6, I got:
crlf: tag: target, line: 2
__lf: tag: target, line: 3
I expect the target is at line 3.
git bisect reports cb927e85 introduced this issue.
With its parent, 19161bab、 I got:
crlf: tag: target, line: 3
__lf: tag: target, line: 3
This issue is derived from https://github.com/universal-ctags/ctags/issues/3851 .