summaryrefslogtreecommitdiff
path: root/gcc/diagnostic.c
diff options
context:
space:
mode:
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-06 22:51:36 +0000
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-06 22:51:36 +0000
commit13225ff5797aafcf9364ad2334a637c23f63f5cb (patch)
tree44627b6221b370fdd68008a052a86fa6e7c16f32 /gcc/diagnostic.c
parent589468a60a5517c8df8a93f35e5ebbe5785834e8 (diff)
downloadgcc-13225ff5797aafcf9364ad2334a637c23f63f5cb.tar.gz
Revert "preprocessor/58580 - preprocessor goes OOM with warning for zero literals"
This reverts commit fc3eff8854861fcd70d33d26095b17fe456fae31. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204490 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r--gcc/diagnostic.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index e0c5d9dc79a..36094a19c9a 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -259,13 +259,12 @@ diagnostic_build_prefix (diagnostic_context *context,
MAX_WIDTH by some margin, then adjust the start of the line such
that the COLUMN is smaller than MAX_WIDTH minus the margin. The
margin is either 10 characters or the difference between the column
- and the length of the line, whatever is smaller. The length of
- LINE is given by LINE_WIDTH. */
+ and the length of the line, whatever is smaller. */
static const char *
-adjust_line (const char *line, int line_width,
- int max_width, int *column_p)
+adjust_line (const char *line, int max_width, int *column_p)
{
int right_margin = 10;
+ int line_width = strlen (line);
int column = *column_p;
right_margin = MIN (line_width - column, right_margin);
@@ -285,7 +284,6 @@ diagnostic_show_locus (diagnostic_context * context,
const diagnostic_info *diagnostic)
{
const char *line;
- int line_width;
char *buffer;
expanded_location s;
int max_width;
@@ -299,25 +297,22 @@ diagnostic_show_locus (diagnostic_context * context,
context->last_location = diagnostic->location;
s = expand_location_to_spelling_point (diagnostic->location);
- line = location_get_source_line (s, &line_width);
+ line = location_get_source_line (s);
if (line == NULL)
return;
max_width = context->caret_max_width;
- line = adjust_line (line, line_width, max_width, &(s.column));
+ line = adjust_line (line, max_width, &(s.column));
pp_newline (context->printer);
saved_prefix = pp_get_prefix (context->printer);
pp_set_prefix (context->printer, NULL);
pp_space (context->printer);
- while (max_width > 0 && line_width > 0)
+ while (max_width > 0 && *line != '\0')
{
char c = *line == '\t' ? ' ' : *line;
- if (c == '\0')
- c = ' ';
pp_character (context->printer, c);
max_width--;
- line_width--;
line++;
}
pp_newline (context->printer);