gdbsupport: re-indent ptrace.m4
[deliverable/binutils-gdb.git] / binutils / mclex.c
index 83b4fd10dc71475d3b5acd39bfabcac191703b56..0cf85eeddd454a9bb1beda95a5b4d0d07c77949e 100644 (file)
@@ -1,5 +1,5 @@
 /* mclex.c -- lexer for Windows mc files parser.
-   Copyright (C) 2007-2016 Free Software Foundation, Inc.
+   Copyright (C) 2007-2020 Free Software Foundation, Inc.
 
    Written by Kai Tietz, Onevision.
 
@@ -323,6 +323,24 @@ mc_token (const unichar *t, size_t len)
   return -1;
 }
 
+/* Skip characters in input_stream_pos up to and including a newline
+   character.  Returns non-zero if the newline was found, zero otherwise.  */
+
+static int
+skip_until_eol (void)
+{
+  while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n')
+    ++input_stream_pos;
+  if (input_stream_pos[0] == 0)
+    return 0;
+  if (input_stream_pos[0] == '\n')
+    {
+      ++input_stream_pos;
+      input_line += 1;
+    }
+  return 1;
+}
+
 int
 yylex (void)
 {
@@ -334,27 +352,28 @@ yylex (void)
       fatal ("Input stream not setuped.\n");
       return -1;
     }
+
   if (mclex_want_line)
     {
       start_token = input_stream_pos;
+      if (input_stream_pos[0] == 0)
+       return -1;
+      /* PR 26082: Reject a period followed by EOF.  */
+      if (input_stream_pos[0] == '.' && input_stream_pos[1] == 0)
+       return -1;
       if (input_stream_pos[0] == '.'
          && (input_stream_pos[1] == '\n'
              || (input_stream_pos[1] == '\r' && input_stream_pos[2] == '\n')))
-      {
-       mclex_want_line = FALSE;
-       while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n')
-         ++input_stream_pos;
-       if (input_stream_pos[0] == '\n')
-         ++input_stream_pos;
-       return MCENDLINE;
-      }
-      while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n')
-       ++input_stream_pos;
-      if (input_stream_pos[0] == '\n')
-       ++input_stream_pos;
+       {
+         mclex_want_line = FALSE;
+          return skip_until_eol () ? MCENDLINE : -1;
+       }
+      if (!skip_until_eol ())
+       return -1;
       yylval.ustr = get_diff (input_stream_pos, start_token);
       return MCLINE;
     }
+
   while ((ch = input_stream_pos[0]) <= 0x20)
     {
       if (ch == 0)
@@ -402,10 +421,8 @@ yylex (void)
   {
   case ';':
     ++start_token;
-    while (input_stream_pos[0] != '\n' && input_stream_pos[0] != 0)
-      ++input_stream_pos;
-    if (input_stream_pos[0] == '\n')
-      input_stream_pos++;
+    if (!skip_until_eol ())
+      return -1;
     yylval.ustr = get_diff (input_stream_pos, start_token);
     return MCCOMMENT;
   case '=':
This page took 0.024515 seconds and 4 git commands to generate.