diff options
author | obrien <obrien@FreeBSD.org> | 2002-02-01 18:16:02 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2002-02-01 18:16:02 +0000 |
commit | c9ab9ae440a8066b2c2b85b157b1fdadcf09916a (patch) | |
tree | 086d9d6c8fbd4fc8fe4495059332f66bc0f8d12b /contrib/gcc/scan.c | |
parent | 2ecfd8bd04b63f335c1ec6295740a4bfd97a4fa6 (diff) | |
download | FreeBSD-src-c9ab9ae440a8066b2c2b85b157b1fdadcf09916a.zip FreeBSD-src-c9ab9ae440a8066b2c2b85b157b1fdadcf09916a.tar.gz |
Enlist the FreeBSD-CURRENT users as testers of what is to become Gcc 3.1.0.
These bits are taken from the FSF anoncvs repo on 1-Feb-2002 08:20 PST.
Diffstat (limited to 'contrib/gcc/scan.c')
-rw-r--r-- | contrib/gcc/scan.c | 72 |
1 files changed, 44 insertions, 28 deletions
diff --git a/contrib/gcc/scan.c b/contrib/gcc/scan.c index 156cd0e..ee2607c 100644 --- a/contrib/gcc/scan.c +++ b/contrib/gcc/scan.c @@ -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 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 @@ -35,10 +35,7 @@ make_sstring_space (str, count) if (new_size <= cur_size) return; - if (str->base == NULL) - str->base = xmalloc (new_size); - else - str->base = xrealloc (str->base, new_size); + str->base = xrealloc (str->base, new_size); str->ptr = str->base + cur_size; str->limit = str->base + new_size; } @@ -48,9 +45,10 @@ sstring_append (dst, src) sstring *dst; sstring *src; { - register char *d, *s; - register int count = SSTRING_LENGTH(src); - MAKE_SSTRING_SPACE(dst, count + 1); + char *d, *s; + int count = SSTRING_LENGTH (src); + + MAKE_SSTRING_SPACE (dst, count + 1); d = dst->ptr; s = src->base; while (--count >= 0) *d++ = *s++; @@ -60,33 +58,34 @@ sstring_append (dst, src) int scan_ident (fp, s, c) - register FILE *fp; - register sstring *s; + 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) - register FILE *fp; - register sstring *s; + FILE *fp; + sstring *s; int init; { int c; + for (;;) { c = getc (fp); @@ -105,9 +104,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; } @@ -116,7 +115,7 @@ scan_string (fp, s, init) int skip_spaces (fp, c) - register FILE *fp; + FILE *fp; int c; { for (;;) @@ -159,24 +158,26 @@ read_upto (fp, str, delim) int delim; { int ch; + for (;;) { 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) - register FILE *fp; - register sstring *s; + FILE *fp; + sstring *s; { int c; + s->ptr = s->base; retry: c = ' '; @@ -214,14 +215,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); @@ -233,9 +234,24 @@ 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; +{ + unsigned int n = len; + unsigned int r = 0; + const unsigned char *s = (const unsigned char *) str; + + do + r = r * 67 + (*s++ - 113); + while (--n); + return r + len; +} |