aboutsummaryrefslogtreecommitdiff
path: root/gcc/read-md.c
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2010-06-10 20:23:00 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2010-06-10 20:23:00 +0000
commit7f7c467fed603c8ad387e731d99ad889e7f2a501 (patch)
tree91d59b44f33747a188102e54bc43cca44943e99a /gcc/read-md.c
parent9f418533f26281f5d9bf776d9d18605f8b2c3b0f (diff)
downloadgcc-7f7c467fed603c8ad387e731d99ad889e7f2a501.zip
gcc-7f7c467fed603c8ad387e731d99ad889e7f2a501.tar.gz
gcc-7f7c467fed603c8ad387e731d99ad889e7f2a501.tar.bz2
read-md.h (read_char): Increment read_md_lineno after reading '\n'.
gcc/ * read-md.h (read_char): Increment read_md_lineno after reading '\n'. (unread_char): Decrement read_md_lineno after putting back '\n'. * read-md.c (fatal_with_file_and_line): Push back any characters that we decide not to add to the context. (read_skip_spaces): Don't increment read_md_lineno here. Avoid using fatal_expected_char in cases where '/' ends a line (for example). (read_name): Don't increment read_md_lineno here. (read_escape): Likewise. (read_quoted_string): Likewise. (read_braced_string): Likewise. From-SVN: r160576
Diffstat (limited to 'gcc/read-md.c')
-rw-r--r--gcc/read-md.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/gcc/read-md.c b/gcc/read-md.c
index 07882aa..1402921 100644
--- a/gcc/read-md.c
+++ b/gcc/read-md.c
@@ -259,7 +259,10 @@ fatal_with_file_and_line (const char *msg, ...)
if (c == EOF)
break;
if (c == '\r' || c == '\n')
- break;
+ {
+ unread_char (c);
+ break;
+ }
context[i] = c;
}
context[i] = '\0';
@@ -298,18 +301,13 @@ read_skip_spaces (void)
c = read_char ();
switch (c)
{
- case '\n':
- read_md_lineno++;
- break;
-
- case ' ': case '\t': case '\f': case '\r':
+ case ' ': case '\t': case '\f': case '\r': case '\n':
break;
case ';':
do
c = read_char ();
while (c != '\n' && c != EOF);
- read_md_lineno++;
break;
case '/':
@@ -317,14 +315,15 @@ read_skip_spaces (void)
int prevc;
c = read_char ();
if (c != '*')
- fatal_expected_char ('*', c);
+ {
+ unread_char (c);
+ fatal_with_file_and_line ("stray '/' in file");
+ }
prevc = 0;
while ((c = read_char ()) && c != EOF)
{
- if (c == '\n')
- read_md_lineno++;
- else if (prevc == '*' && c == '/')
+ if (prevc == '*' && c == '/')
break;
prevc = c;
}
@@ -370,8 +369,6 @@ read_name (struct md_name *name)
if (i == 0)
fatal_with_file_and_line ("missing name or number");
- if (c == '\n')
- read_md_lineno++;
name->buffer[i] = 0;
name->string = name->buffer;
@@ -406,7 +403,6 @@ read_escape (void)
{
/* Backslash-newline is replaced by nothing, as in C. */
case '\n':
- read_md_lineno++;
return;
/* \" \' \\ are replaced by the second character. */
@@ -458,9 +454,7 @@ read_quoted_string (void)
while (1)
{
c = read_char (); /* Read the string */
- if (c == '\n')
- read_md_lineno++;
- else if (c == '\\')
+ if (c == '\\')
{
read_escape ();
continue;
@@ -491,9 +485,7 @@ read_braced_string (void)
{
c = read_char (); /* Read the string */
- if (c == '\n')
- read_md_lineno++;
- else if (c == '{')
+ if (c == '{')
brace_depth++;
else if (c == '}')
brace_depth--;