diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2018-01-27 06:44:25 +0000 |
---|---|---|
committer | Bernd Edlinger <edlinger@gcc.gnu.org> | 2018-01-27 06:44:25 +0000 |
commit | d76ba10db121e71a7a668b40df259a2893086da3 (patch) | |
tree | ed14e17cec1e85b5ba3fec361e74caed47eff2ea | |
parent | 0f06be5a06718ce7b670f4ffe9f971a830381757 (diff) | |
download | gcc-d76ba10db121e71a7a668b40df259a2893086da3.zip gcc-d76ba10db121e71a7a668b40df259a2893086da3.tar.gz gcc-d76ba10db121e71a7a668b40df259a2893086da3.tar.bz2 |
re PR middle-end/84034 (incomplete warning message with dos line endings)
2018-01-27 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR diagnostic/84034
* diagnostic-show-locus.c (get_line_width_without_trailing_whitespace):
Handle CR like TAB.
(layout::print_source_line): Likewise.
(test_get_line_width_without_trailing_whitespace): Add test cases.
From-SVN: r257120
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/diagnostic-show-locus.c | 11 |
2 files changed, 15 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f2699e0..981ae01 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-01-27 Bernd Edlinger <bernd.edlinger@hotmail.de> + + PR diagnostic/84034 + * diagnostic-show-locus.c (get_line_width_without_trailing_whitespace): + Handle CR like TAB. + (layout::print_source_line): Likewise. + (test_get_line_width_without_trailing_whitespace): Add test cases. + 2018-01-27 Jakub Jelinek <jakub@redhat.com> PR middle-end/84040 diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c index cce3ef3..5eee3cc 100644 --- a/gcc/diagnostic-show-locus.c +++ b/gcc/diagnostic-show-locus.c @@ -639,7 +639,7 @@ get_line_width_without_trailing_whitespace (const char *line, int line_width) while (result > 0) { char ch = line[result - 1]; - if (ch == ' ' || ch == '\t') + if (ch == ' ' || ch == '\t' || ch == '\r') result--; else break; @@ -648,7 +648,8 @@ get_line_width_without_trailing_whitespace (const char *line, int line_width) gcc_assert (result <= line_width); gcc_assert (result == 0 || (line[result - 1] != ' ' - && line[result -1] != '\t')); + && line[result -1] != '\t' + && line[result -1] != '\r')); return result; } @@ -673,9 +674,11 @@ test_get_line_width_without_trailing_whitespace () assert_eq ("", 0); assert_eq (" ", 0); assert_eq ("\t", 0); + assert_eq ("\r", 0); assert_eq ("hello world", 11); assert_eq ("hello world ", 11); assert_eq ("hello world \t\t ", 11); + assert_eq ("hello world\r", 11); } #endif /* #if CHECKING_P */ @@ -1176,8 +1179,8 @@ layout::print_source_line (int row, const char *line, int line_width, else m_colorizer.set_normal_text (); } - char c = *line == '\t' ? ' ' : *line; - if (c == '\0') + char c = *line; + if (c == '\0' || c == '\t' || c == '\r') c = ' '; if (c != ' ') { |