/* Utility functions for scan-decls and fix-header programs.
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1998 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
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-#include "scan.h"
#include "hconfig.h"
-#include <ctype.h>
+#include "system.h"
+#include "scan.h"
int lineno = 1;
int source_lineno = 1;
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;
}
sstring *src;
{
register char *d, *s;
- register count = SSTRING_LENGTH(src);
+ register int count = SSTRING_LENGTH(src);
MAKE_SSTRING_SPACE(dst, count + 1);
d = dst->ptr;
s = src->base;
int c;
{
s->ptr = s->base;
- if (isalpha(c) || c == '_')
+ if (ISALPHA(c) || c == '_')
{
for (;;)
{
SSTRING_PUT(s, c);
c = getc (fp);
- if (c == EOF || !(isalnum(c) || c == '_'))
+ if (c == EOF || !(ISALNUM(c) || c == '_'))
break;
}
}
scan_string (fp, s, init)
register FILE *fp;
register sstring *s;
+ int init;
{
int c;
for (;;)
return c;
}
-/* Skip horizontal white spaces (spaces, tabs, and C-style comments). */
+/* Skip horizontal white spaces (spaces, tabs, and C-style comments). */
int
skip_spaces (fp, c)
}
if (c == EOF)
return EOF;
- if (isdigit (c))
+ if (ISDIGIT (c))
{
do
{
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 (ISALPHA (c) || c == '_')
{
c = scan_ident (fp, s, c);
ungetc (c, fp);
*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;
+}