* rclex.l (handle_quotes): Fix minor formatting problems introduced in previous
[deliverable/binutils-gdb.git] / binutils / rclex.l
index 47b479b20b6f941c0118840648808e4feaa8bfb2..3a4f3e1df8e03b95f7b2109593cf561fe59d3536 100644 (file)
@@ -1,5 +1,5 @@
 %{ /* rclex.l -- lexer for Windows rc files parser  */
-/* Copyright 1997, 1998 Free Software Foundation, Inc.
+/* Copyright 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
    This file is part of GNU Binutils.
 #include "bfd.h"
 #include "bucomm.h"
 #include "libiberty.h"
+#include "safe-ctype.h"
 #include "windres.h"
 #include "rcparse.h"
 
-#include <ctype.h>
 #include <assert.h>
 
 /* Whether we are in rcdata mode, in which we returns the lengths of
@@ -196,7 +196,7 @@ static char *get_string PARAMS ((int));
                          MAYBE_RETURN (NUMBER);
                        }
 
-("\""[^\"\n]*"\""[ \t]*)+ {
+("\""[^\"\n]*"\""[ \t\n]*)+ {
                          char *s;
                          unsigned long length;
 
@@ -252,18 +252,18 @@ cpp_line (s)
   char *send, *fn;
 
   ++s;
-  while (isspace ((unsigned char) *s))
+  while (ISSPACE (*s))
     ++s;
   
   line = strtol (s, &send, 0);
-  if (*send != '\0' && ! isspace ((unsigned char) *send))
+  if (*send != '\0' && ! ISSPACE (*send))
     return;
 
   /* Subtract 1 because we are about to count the newline.  */
   rc_lineno = line - 1;
 
   s = send;
-  while (isspace ((unsigned char) *s))
+  while (ISSPACE (*s))
     ++s;
 
   if (*s != '"')
@@ -284,11 +284,11 @@ cpp_line (s)
   if (!initial_fn)
     {
       initial_fn = xmalloc (strlen (fn) + 1);
-      strcpy(initial_fn, fn);
+      strcpy (initial_fn, fn);
     }
 
   /* Allow the initial file, regardless of name.  Suppress all other
-     files if they end in ".h" (this allows included "*.rc") */
+     files if they end in ".h" (this allows included "*.rc") */
   if (strcmp (initial_fn, fn) == 0
       || strcmp (fn + strlen (fn) - 2, ".h") != 0)
     suppress_cpp_data = 0;
@@ -331,7 +331,7 @@ handle_quotes (input, len)
              break;
 
            case 'a':
-             *s++ = ESCAPE_A;
+             *s++ = ESCAPE_B; /* Strange, but true...  */
              ++t;
              break;
 
@@ -394,9 +394,9 @@ handle_quotes (input, len)
                  if (*t >= '0' && *t <= '9')
                    ch = (ch << 4) | (*t - '0');
                  else if (*t >= 'a' && *t <= 'f')
-                   ch = (ch << 4) | (*t - 'a');
+                   ch = (ch << 4) | (*t - 'a' + 10);
                  else if (*t >= 'A' && *t <= 'F')
-                   ch = (ch << 4) | (*t - 'A');
+                   ch = (ch << 4) | (*t - 'A' + 10);
                  else
                    break;
                  ++t;
@@ -423,9 +423,13 @@ handle_quotes (input, len)
       else
        {
          ++t;
-         assert (isspace ((unsigned char) *t));
-         while (isspace ((unsigned char) *t))
-           ++t;
+         assert (ISSPACE (*t));
+         while (ISSPACE (*t))
+           {
+             if ((*t) == '\n')
+               ++rc_lineno;
+             ++t;
+           }
          if (*t == '\0')
            break;
          assert (*t == '"');
@@ -452,7 +456,7 @@ get_string (len)
   as->s = xmalloc (len);
 
   as->next = strings;
-  strings = as->next;
+  strings = as;
 
   return as->s;
 }
This page took 0.024858 seconds and 4 git commands to generate.