]>
gcc.gnu.org Git - gcc.git/blob - gcc/scan.c
1 /* Utility functions for scan-decls and fix-header programs.
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 2, or (at your option) any
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
23 int source_lineno
= 1;
24 sstring source_filename
;
27 make_sstring_space (str
, count
)
31 int cur_pos
= str
->ptr
- str
->base
;
32 int cur_size
= str
->limit
- str
->base
;
33 int new_size
= cur_pos
+ count
+ 100;
35 if (new_size
<= cur_size
)
38 if (str
->base
== NULL
)
39 str
->base
= xmalloc (new_size
);
41 str
->base
= xrealloc (str
->base
, new_size
);
42 str
->ptr
= str
->base
+ cur_size
;
43 str
->limit
= str
->base
+ new_size
;
47 sstring_append (dst
, src
)
52 register count
= SSTRING_LENGTH(src
);
53 MAKE_SSTRING_SPACE(dst
, count
+ 1);
56 while (--count
>= 0) *d
++ = *s
++;
70 register char *ptr
= (char *) malloc (size
);
71 if (ptr
!= 0) return (ptr
);
83 register char *ptr
= (char *) realloc (old
, size
);
84 if (ptr
!= 0) return (ptr
);
97 if (isalpha(c
) || c
== '_')
103 if (c
== EOF
|| !(isalnum(c
) || c
== '_'))
107 MAKE_SSTRING_SPACE(s
, 1);
113 scan_string (fp
, s
, init
)
121 if (c
== EOF
|| c
== '\n')
138 MAKE_SSTRING_SPACE(s
, 1);
143 /* Skip horizontal white spaces (spaces, tabs, and C-style comments). */
152 if (c
== ' ' || c
== '\t')
170 source_lineno
++, lineno
++;
173 else if ((c
= getc (fp
)) == '/')
184 read_upto (fp
, str
, delim
)
193 if (ch
== EOF
|| ch
== delim
)
195 SSTRING_PUT(str
, ch
);
197 MAKE_SSTRING_SPACE(str
, 1);
211 c
= skip_spaces (fp
, c
);
220 c
= get_token (fp
, s
);
223 source_lineno
= atoi (s
->base
) - 1; /* '\n' will add 1 */
224 get_token (fp
, &source_filename
);
247 } while (c
!= EOF
&& isdigit(c
));
252 if (isalpha (c
) || c
== '_')
254 c
= scan_ident (fp
, s
, c
);
256 return IDENTIFIER_TOKEN
;
258 if (c
== '\'' || c
== '"')
260 c
= scan_string (fp
, s
, c
);
262 return c
== '\'' ? CHAR_TOKEN
: STRING_TOKEN
;
266 MAKE_SSTRING_SPACE(s
, 1);
276 /* Replace this with something faster/better! FIXME! */
277 while (*str
) h
= (h
<< 3) + *str
++;
278 return h
& 0x7FFFFFFF;
This page took 0.046712 seconds and 5 git commands to generate.