OSDN Git Service

2006-02-20 Paolo Bonzini <bonzini@gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / scan.c
index e9a9a4b..d5d7bee 100644 (file)
@@ -1,5 +1,5 @@
 /* Utility functions for scan-decls and fix-header programs.
-   Copyright (C) 1993, 1994, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1998, 2002, 2003 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
@@ -13,10 +13,12 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#include "hconfig.h"
+#include "bconfig.h"
 #include "system.h"
+#include "coretypes.h"
+#include "tm.h"
 #include "scan.h"
 
 int lineno = 1;
@@ -24,9 +26,7 @@ int source_lineno = 1;
 sstring source_filename;
 
 void
-make_sstring_space (str, count)
-     sstring *str;
-     int count;
+make_sstring_space (sstring *str, int count)
 {
   int cur_pos = str->ptr - str->base;
   int cur_size = str->limit - str->base;
@@ -34,55 +34,47 @@ make_sstring_space (str, count)
 
   if (new_size <= cur_size)
     return;
-  
+
   str->base = xrealloc (str->base, new_size);
   str->ptr = str->base + cur_size;
   str->limit = str->base + new_size;
 }
 
 void
-sstring_append (dst, src)
-     sstring *dst;
-     sstring *src;
+sstring_append (sstring *dst, sstring *src)
 {
   char *d, *s;
-  int count = SSTRING_LENGTH(src);
+  int count = SSTRING_LENGTH (src);
 
-  MAKE_SSTRING_SPACE(dst, count + 1);
+  MAKE_SSTRING_SPACE (dst, count + 1);
   d = dst->ptr;
   s = src->base;
   while (--count >= 0) *d++ = *s++;
   dst->ptr = d;
-  *d = 0;  
+  *d = 0;
 }
 
 int
-scan_ident (fp, s, c)
-     FILE *fp;
-     sstring *s;
-     int c;
+scan_ident (FILE *fp, sstring *s, int c)
 {
   s->ptr = s->base;
-  if (ISALPHA(c) || c == '_')
+  if (ISIDST (c))
     {
       for (;;)
        {
-         SSTRING_PUT(s, c);
+         SSTRING_PUT (s, c);
          c = getc (fp);
-         if (c == EOF || !(ISALNUM(c) || c == '_'))
+         if (c == EOF || ! ISIDNUM (c))
            break;
        }
     }
-  MAKE_SSTRING_SPACE(s, 1);
+  MAKE_SSTRING_SPACE (s, 1);
   *s->ptr = 0;
   return c;
 }
 
 int
-scan_string (fp, s, init)
-     FILE *fp;
-     sstring *s;
-     int init;
+scan_string (FILE *fp, sstring *s, int init)
 {
   int c;
 
@@ -104,9 +96,9 @@ scan_string (fp, s, init)
          if (c == '\n')
            continue;
        }
-      SSTRING_PUT(s, c);
+      SSTRING_PUT (s, c);
     }
-  MAKE_SSTRING_SPACE(s, 1);
+  MAKE_SSTRING_SPACE (s, 1);
   *s->ptr = 0;
   return c;
 }
@@ -114,9 +106,7 @@ scan_string (fp, s, init)
 /* Skip horizontal white spaces (spaces, tabs, and C-style comments).  */
 
 int
-skip_spaces (fp, c)
-     FILE *fp;
-     int c;
+skip_spaces (FILE *fp, int c)
 {
   for (;;)
     {
@@ -152,10 +142,7 @@ skip_spaces (fp, c)
 }
 
 int
-read_upto (fp, str, delim)
-     FILE *fp;
-     sstring *str;
-     int delim;
+read_upto (FILE *fp, sstring *str, int delim)
 {
   int ch;
 
@@ -164,17 +151,15 @@ read_upto (fp, str, delim)
       ch = getc (fp);
       if (ch == EOF || ch == delim)
        break;
-      SSTRING_PUT(str, ch);
+      SSTRING_PUT (str, ch);
     }
-  MAKE_SSTRING_SPACE(str, 1);
+  MAKE_SSTRING_SPACE (str, 1);
   *str->ptr = 0;
   return ch;
 }
 
 int
-get_token (fp, s)
-     FILE *fp;
-     sstring *s;
+get_token (FILE *fp, sstring *s)
 {
   int c;
 
@@ -215,14 +200,14 @@ get_token (fp, s)
     {
       do
        {
-         SSTRING_PUT(s, c);
+         SSTRING_PUT (s, c);
          c = getc (fp);
-       } while (c != EOF && ISDIGIT(c));
+       } while (c != EOF && ISDIGIT (c));
       ungetc (c, fp);
       c = INT_TOKEN;
       goto done;
     }
-  if (ISALPHA (c) || c == '_')
+  if (ISIDST (c))
     {
       c = scan_ident (fp, s, c);
       ungetc (c, fp);
@@ -234,21 +219,19 @@ get_token (fp, s)
       ungetc (c, fp);
       return c == '\'' ? CHAR_TOKEN : STRING_TOKEN;
     }
-  SSTRING_PUT(s, c);
+  SSTRING_PUT (s, c);
  done:
-  MAKE_SSTRING_SPACE(s, 1);
+  MAKE_SSTRING_SPACE (s, 1);
   *s->ptr = 0;
   return c;
 }
 
 unsigned int
-hashstr (str, len)
-     const char *str;
-     unsigned int len;
+hashstr (const char *str, unsigned int len)
 {
   unsigned int n = len;
   unsigned int r = 0;
-  const unsigned char *s = (const unsigned char *)str;
+  const unsigned char *s = (const unsigned char *) str;
 
   do
     r = r * 67 + (*s++ - 113);