This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
'\r' only end-of-line
As discussed in thread
http://sources.redhat.com/ml/gdb-patches/2006-10/msg00090.html
about the TUI that did not display windows source files,
I propose a patch that treats source files where end-of-line are '\r' only.
The struct symtab fulfilled by find_source_lines was wrong, the field
nlines was set to 1.
Therefore these files can not be open in the TUI for instance.
Denis
2006-10-10 Denis PILAT <denis.pilat@st.com>
* source.c (find_source_lines): Treat the case of source
file whith '\r' only end-of-line.
Index: source.c
===================================================================
--- source.c (revision 528)
+++ source.c (working copy)
@@ -1074,7 +1074,11 @@ find_source_lines (struct symtab *s, int
nlines = 1;
while (p != end)
{
- if (*p++ == '\n'
+ /* Skip the \r in case of \r\n end-of-line. */
+ if (*p == '\r' && *(p + 1) == '\n')
+ p++;
+ /* Lines could end with '\n' or '\r' only. */
+ if ((*p == '\n' || *p == '\r')
/* A newline at the end does not start a new line. */
&& p != end)
{
@@ -1085,8 +1089,9 @@ find_source_lines (struct symtab *s, int
(int *) xrealloc ((char *) line_charpos,
sizeof (int) * lines_allocated);
}
- line_charpos[nlines++] = p - data;
+ line_charpos[nlines++] = p + 1 - data;
}
+ p++;
}
do_cleanups (old_cleanups);
}