{
char buf[20];
- sprintf (buf, "$cdir%c$cwd", DIRNAME_SEPARATOR);
+ xsnprintf (buf, sizeof (buf), "$cdir%c$cwd", DIRNAME_SEPARATOR);
source_path = xstrdup (buf);
forget_cached_source_info ();
}
/* Print source lines from the file of symtab S,
starting with line number LINE and stopping before line number STOPLINE. */
-static void print_source_lines_base (struct symtab *s, int line, int stopline,
- int noerror);
static void
-print_source_lines_base (struct symtab *s, int line, int stopline, int noerror)
+print_source_lines_base (struct symtab *s, int line, int stopline,
+ enum print_source_lines_flags flags)
{
int c;
int desc;
else
{
desc = last_source_error;
- noerror = 1;
+ flags |= PRINT_SOURCE_LINES_NOERROR;
}
}
else
{
desc = last_source_error;
- noerror = 1;
+ flags |= PRINT_SOURCE_LINES_NOERROR;
noprint = 1;
}
{
last_source_error = desc;
- if (!noerror)
+ if (!(flags & PRINT_SOURCE_LINES_NOERROR))
{
- char *name = alloca (strlen (s->filename) + 100);
- sprintf (name, "%d\t%s", line, s->filename);
+ int len = strlen (s->filename) + 100;
+ char *name = alloca (len);
+
+ xsnprintf (name, len, "%d\t%s", line, s->filename);
print_sys_errmsg (name, errno);
}
else
ui_out_field_int (uiout, "line", line);
ui_out_text (uiout, "\tin ");
ui_out_field_string (uiout, "file", s->filename);
+ if (ui_out_is_mi_like_p (uiout))
+ {
+ const char *fullname = symtab_to_fullname (s);
+
+ if (fullname != NULL)
+ ui_out_field_string (uiout, "fullname", fullname);
+ }
ui_out_text (uiout, "\n");
}
if (c == EOF)
break;
last_line_listed = current_source_line;
- sprintf (buf, "%d\t", current_source_line++);
+ if (flags & PRINT_SOURCE_LINES_FILENAME)
+ {
+ ui_out_text (uiout, s->filename);
+ ui_out_text (uiout, ":");
+ }
+ xsnprintf (buf, sizeof (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);
+ xsnprintf (buf, sizeof (buf), "^%c", c + 0100);
ui_out_text (uiout, buf);
}
else if (c == 0177)
}
else
{
- sprintf (buf, "%c", c);
+ xsnprintf (buf, sizeof (buf), "%c", c);
ui_out_text (uiout, buf);
}
}
window otherwise it is simply printed. */
void
-print_source_lines (struct symtab *s, int line, int stopline, int noerror)
+print_source_lines (struct symtab *s, int line, int stopline,
+ enum print_source_lines_flags flags)
{
- print_source_lines_base (s, line, stopline, noerror);
+ print_source_lines_base (s, line, stopline, flags);
}
\f
/* Print info on range of pc's in a specified line. */