[PATCH] TUI, Source files with CRLF line endings

Ton van Overbeek v-overbeek@cistron.nl
Tue Oct 1 07:07:00 GMT 2002


When dealing with source files containing DOS CR/LF line-endings
on Cygwin I found that these did not get correctly displayed in
TUI's source window. Every line from the top of the window is
followed by an extra empty line.
This can happen on Cygwin if you open a DOS file with CR/LF line-endings
on a binary mounted file system.
The fix is to add some logic to tuiSetSourceContent to swallow the extra
LF characters[B.
Changelog entry and patch attached.

2002-10-01	Ton van Overbeek (v-overbeek@cistron.nl)
	* tuiSource.c (tuiSetSourceContent): Eat the extra '\n' in
	source files containing '\r\n' line endings.

Ton van Overbeek

-------------- next part --------------
--- tui/tuiSource.c.orig	2002-09-01 18:12:52.000000000 +0200
+++ tui/tuiSource.c	2002-09-29 16:30:54.000000000 +0200
@@ -210,6 +210,12 @@ tuiSetSourceContent (struct symtab *s, i
 			    }
 			  while (c != EOF && c != '\n' && c != '\r' &&
 				 i < threshold && (c = fgetc (stream)));
+                          if (c == '\r')
+                            {  /* eat the '\n' if we have a '\r','\n' combo,
+                                  e.g. with DOS files on a bin Cygwin mount */
+                               c = fgetc (stream);
+                               if (c != '\n') ungetc (c, stream);
+                            }
 			}
 		      /* Now copy the line taking the offset into account */
 		      if (strlen (srcLine) > offset)


More information about the Gdb-patches mailing list