]>
gcc.gnu.org Git - gcc.git/blob - gcc/scan.c
1 /* scan.c - Utility functions for scan-decls and patch-header programs.
2 Copyright (C) 1993 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. */
22 int source_lineno
= 1;
23 sstring source_filename
;
26 make_sstring_space (str
, count
)
30 int cur_pos
= str
->ptr
- str
->base
;
31 int cur_size
= str
->limit
- str
->base
;
32 int new_size
= cur_pos
+ count
+ 100;
34 if (new_size
<= cur_size
)
37 if (str
->base
== NULL
)
38 str
->base
= xmalloc (new_size
);
40 str
->base
= xrealloc (str
->base
, new_size
);
41 str
->ptr
= str
->base
+ cur_size
;
42 str
->limit
= str
->base
+ new_size
;
46 sstring_append (dst
, src
)
51 register count
= SSTRING_LENGTH(src
);
52 MAKE_SSTRING_SPACE(dst
, count
+ 1);
55 while (--count
>= 0) *d
++ = *s
++;
69 register char *ptr
= (char *) malloc (size
);
70 if (ptr
!= 0) return (ptr
);
82 register char *ptr
= (char *) realloc (old
, size
);
83 if (ptr
!= 0) return (ptr
);
96 if (isalpha(c
) || c
== '_')
102 if (c
== EOF
|| !(isalnum(c
) || c
== '_'))
106 MAKE_SSTRING_SPACE(s
, 1);
112 scan_string (fp
, s
, init
)
120 if (c
== EOF
|| c
== '\n')
137 MAKE_SSTRING_SPACE(s
, 1);
142 /* Skip horizontal white spaces (spaces, tabs, and C-style comments). */
151 if (c
== ' ' || c
== '\t')
169 source_lineno
++, lineno
++;
172 else if ((c
= getc (fp
)) == '/')
183 read_upto (fp
, str
, delim
)
192 if (ch
== EOF
|| ch
== delim
)
194 SSTRING_PUT(str
, ch
);
196 MAKE_SSTRING_SPACE(str
, 1);
211 c
= skip_spaces (fp
, c
);
220 c
= get_token (fp
, s
);
223 source_lineno
= atoi (s
->base
);
224 get_token (fp
, &source_filename
);
243 } while (c
!= EOF
&& isdigit(c
));
248 if (isalpha (c
) || c
== '_')
250 c
= scan_ident (fp
, s
, c
);
252 return IDENTIFIER_TOKEN
;
254 if (c
== '\'' || c
== '"')
257 c
= scan_string (fp
, s
, c
);
259 return c
== '\'' ? CHAR_TOKEN
: STRING_TOKEN
;
263 MAKE_SSTRING_SPACE(s
, 1);
273 /* Replace this with something faster/better! FIXME! */
274 while (*str
) h
= (h
<< 3) + *str
++;
275 return h
& 0x7FFFFFFF;
This page took 0.053946 seconds and 6 git commands to generate.