Commit a1b60e49 by Francois-Xavier Coudert Committed by François-Xavier Coudert

re PR fortran/52559 (Spurious \x00 in error messages of lines with tab)

	PR fortran/52559
	* error.c (gfc_widechar_display_length): Consider tabs as
	one character wide, as they're displayed as spaces.
	(show_locus): Move tab handling to...
	(print_wide_char_into_buffer): ... here.

From-SVN: r185517
parent 55c2a83a
2012-03-19 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/52559
* error.c (gfc_widechar_display_length): Consider tabs as
one character wide, as they're displayed as spaces.
(show_locus): Move tab handling to...
(print_wide_char_into_buffer): ... here.
2012-03-17 Tobias Burnus <burnus@net-b.de> 2012-03-17 Tobias Burnus <burnus@net-b.de>
PR fortran/52585 PR fortran/52585
......
...@@ -178,8 +178,8 @@ error_integer (long int i) ...@@ -178,8 +178,8 @@ error_integer (long int i)
static size_t static size_t
gfc_widechar_display_length (gfc_char_t c) gfc_widechar_display_length (gfc_char_t c)
{ {
if (gfc_wide_is_printable (c)) if (gfc_wide_is_printable (c) || c == '\t')
/* Simple ASCII character */ /* Printable ASCII character, or tabulation (output as a space). */
return 1; return 1;
else if (c < ((gfc_char_t) 1 << 8)) else if (c < ((gfc_char_t) 1 << 8))
/* Displayed as \x?? */ /* Displayed as \x?? */
...@@ -213,10 +213,11 @@ print_wide_char_into_buffer (gfc_char_t c, char *buf) ...@@ -213,10 +213,11 @@ print_wide_char_into_buffer (gfc_char_t c, char *buf)
static const char xdigit[16] = { '0', '1', '2', '3', '4', '5', '6', static const char xdigit[16] = { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
if (gfc_wide_is_printable (c)) if (gfc_wide_is_printable (c) || c == '\t')
{ {
buf[1] = '\0'; buf[1] = '\0';
buf[0] = (unsigned char) c; /* Tabulation is output as a space. */
buf[0] = (unsigned char) (c == '\t' ? ' ' : c);
return 1; return 1;
} }
else if (c < ((gfc_char_t) 1 << 8)) else if (c < ((gfc_char_t) 1 << 8))
...@@ -291,7 +292,7 @@ show_locus (locus *loc, int c1, int c2) ...@@ -291,7 +292,7 @@ show_locus (locus *loc, int c1, int c2)
{ {
gfc_linebuf *lb; gfc_linebuf *lb;
gfc_file *f; gfc_file *f;
gfc_char_t c, *p; gfc_char_t *p;
int i, offset, cmax; int i, offset, cmax;
/* TODO: Either limit the total length and number of included files /* TODO: Either limit the total length and number of included files
...@@ -370,12 +371,7 @@ show_locus (locus *loc, int c1, int c2) ...@@ -370,12 +371,7 @@ show_locus (locus *loc, int c1, int c2)
while (i > 0) while (i > 0)
{ {
static char buffer[11]; static char buffer[11];
i -= print_wide_char_into_buffer (*p++, buffer);
c = *p++;
if (c == '\t')
c = ' ';
i -= print_wide_char_into_buffer (c, buffer);
error_string (buffer); error_string (buffer);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment