summaryrefslogtreecommitdiff
path: root/gdb/source.c
diff options
context:
space:
mode:
authorJason Molenda <jsm@bugshack.cygnus.com>2000-02-03 04:14:45 +0000
committerJason Molenda <jsm@bugshack.cygnus.com>2000-02-03 04:14:45 +0000
commit14558c99c9b3adcfd7ab7934392a7b958337a015 (patch)
treeb2e79b25f07d17787cf4551bcf1150420075b5d4 /gdb/source.c
parent5ae8a6a77da8e5101aca60a1add4853b8225dc91 (diff)
downloadgdb-14558c99c9b3adcfd7ab7934392a7b958337a015.tar.gz
import gdb-2000-02-02 snapshot
Diffstat (limited to 'gdb/source.c')
-rw-r--r--gdb/source.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/gdb/source.c b/gdb/source.c
index 358cac9e496..dd26043b2cb 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -38,6 +38,9 @@
#include "objfiles.h"
#include "annotate.h"
#include "gdbtypes.h"
+#ifdef UI_OUT
+#include "ui-out.h"
+#endif
#ifdef CRLF_SOURCE_FILES
@@ -1011,6 +1014,11 @@ print_source_lines_base (s, line, stopline, noerror)
current_source_line = line;
first_line_listed = line;
+#ifdef UI_OUT
+ /* If printing of source lines is disabled, just print file and line number */
+ if (ui_out_test_flags (uiout, ui_source_list))
+ {
+#endif
/* Only prints "No such file or directory" once */
if ((s != last_source_visited) || (!last_source_error))
{
@@ -1022,6 +1030,14 @@ print_source_lines_base (s, line, stopline, noerror)
desc = last_source_error;
noerror = 1;
}
+#ifdef UI_OUT
+ }
+ else
+ {
+ desc = -1;
+ noerror = 1;
+ }
+#endif
if (desc < 0)
{
@@ -1034,7 +1050,14 @@ print_source_lines_base (s, line, stopline, noerror)
print_sys_errmsg (name, errno);
}
else
+#ifdef UI_OUT
+ ui_out_field_int (uiout, "line", line);
+ ui_out_text (uiout, "\tin ");
+ ui_out_field_string (uiout, "file", s->filename);
+ ui_out_text (uiout, "\n");
+#else
printf_filtered ("%d\tin %s\n", line, s->filename);
+#endif
return;
}
@@ -1062,6 +1085,44 @@ print_source_lines_base (s, line, stopline, noerror)
while (nlines-- > 0)
{
+#ifdef UI_OUT
+ char buf[20];
+
+ c = fgetc (stream);
+ if (c == EOF)
+ break;
+ last_line_listed = current_source_line;
+ sprintf (buf, "%d\t", current_source_line++);
+ ui_out_text (uiout, buf);
+ do
+ {
+ if (c < 040 && c != '\t' && c != '\n' && c != '\r')
+ {
+ sprintf (buf, "^%c", c + 0100);
+ ui_out_text (uiout, buf);
+ }
+ else if (c == 0177)
+ ui_out_text (uiout, "^?");
+#ifdef CRLF_SOURCE_FILES
+ else if (c == '\r')
+ {
+ /* Skip a \r character, but only before a \n. */
+ int c1 = fgetc (stream);
+
+ if (c1 != '\n')
+ printf_filtered ("^%c", c + 0100);
+ if (c1 != EOF)
+ ungetc (c1, stream);
+ }
+#endif
+ else
+ {
+ sprintf (buf, "%c", c);
+ ui_out_text (uiout, buf);
+ }
+ }
+ while (c != '\n' && (c = fgetc (stream)) >= 0);
+#else
c = fgetc (stream);
if (c == EOF)
break;
@@ -1083,6 +1144,7 @@ print_source_lines_base (s, line, stopline, noerror)
printf_filtered ("%c", c);
}
while (c != '\n' && (c = fgetc (stream)) >= 0);
+#endif
}
fclose (stream);