This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [TUI] correctly display windows source files




That could be so, but I'd prefer that our code didn't do anything that
could fail, even theoretically.  We shouldn't call functions with
arguments that invoke undefined or uncertain behavior.

It should be a simple matter of adding a test for EOF.

You're right, I can not do testing on all hosts and libc.
Attached a new proposal.

In the case of "'\r'EOF" we keep EOF in "c" variable and we exit the while just below anyway.

Denis
2006-10-09  Denis Pilat  <denis.pilat@st.com>

	* tui-source.c (tui_set_source_content): handle source files that 
	contain non unix end-of-line.

Index: tui/tui-source.c
===================================================================
--- tui/tui-source.c	(revision 529)
+++ tui/tui-source.c	(working copy)
@@ -194,6 +194,14 @@ tui_set_source_content (struct symtab *s
                                            chars until we do  */
 				  while (c != EOF && c != '\n' && c != '\r')
 				    c = fgetc (stream);
+				  /* Handle non-'\n' end-of-line.  */
+				  if (c == '\r' &&
+				     (c = fgetc (stream)) != '\n' && c != EOF)
+				    {
+				       ungetc (c, stream);
+				       c = '\r';
+				    }
+				  
 				}
 			    }
 			  while (c != EOF && c != '\n' && c != '\r' &&

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]