mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 01:03:04 +00:00
diagnostics: style changes
* src/location.c (location_caret): Clarify a bit.
This commit is contained in:
@@ -183,7 +183,8 @@ location_caret (location loc, const char *style, FILE *out)
|
|||||||
int c = getc (caret_info.source);
|
int c = getc (caret_info.source);
|
||||||
if (c != EOF)
|
if (c != EOF)
|
||||||
{
|
{
|
||||||
/* Quote the file, indent by a single column. */
|
/* Quote the file (at most first line in the case of multiline
|
||||||
|
location). Indent by a single column. */
|
||||||
fputc (' ', out);
|
fputc (' ', out);
|
||||||
int col = 0;
|
int col = 0;
|
||||||
do
|
do
|
||||||
@@ -204,17 +205,17 @@ location_caret (location loc, const char *style, FILE *out)
|
|||||||
putc ('\n', out);
|
putc ('\n', out);
|
||||||
|
|
||||||
{
|
{
|
||||||
/* The caret of a multiline location ends with the first line. */
|
/* Print the carets with the same indentation as above. */
|
||||||
size_t len = loc.start.line != loc.end.line
|
|
||||||
? ftell (caret_info.source) - caret_info.offset
|
|
||||||
: loc.end.column;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Print the carets (at least one), with the same indent as above.*/
|
|
||||||
fprintf (out, " %*s", loc.start.column - 1, "");
|
fprintf (out, " %*s", loc.start.column - 1, "");
|
||||||
begin_use_class (style, out);
|
begin_use_class (style, out);
|
||||||
for (i = loc.start.column; i == loc.start.column || i < len; ++i)
|
putc ('^', out);
|
||||||
putc (i == loc.start.column ? '^' : '~', out);
|
/* Underlining a multiline location ends with the first
|
||||||
|
line. */
|
||||||
|
int len = loc.start.line != loc.end.line
|
||||||
|
? ftell (caret_info.source) - caret_info.offset
|
||||||
|
: loc.end.column;
|
||||||
|
for (int i = loc.start.column + 1; i < len; ++i)
|
||||||
|
putc ('~', out);
|
||||||
end_use_class (style, out);
|
end_use_class (style, out);
|
||||||
}
|
}
|
||||||
putc ('\n', out);
|
putc ('\n', out);
|
||||||
|
|||||||
Reference in New Issue
Block a user