Commit 38b24ee2 by Zack Weinberg Committed by Zack Weinberg

cpplib.h (parse_underflow_t, [...]): Delete.

	* cpplib.h (parse_underflow_t, CPP_NULL_BUFFER): Delete.
	(struct cpp_buffer): Remove fname and underflow fields.
	(struct cpp_reader): Remove get_token field.
	(struct include_hash): Rename to struct ihash.  Add typedef to
	IHASH.
	(struct if_stack): Remove fname field.
	(IF_STACK_FRAME): Rename to IF_STACK.

	* cpperror.c (print_containing_files): Trust that there are no
	macro buffers below the top file buffer.
	* cppfiles.c: Replace all references to 'struct include_hash'
	with 'IHASH'.  Rename initialize_input_buffer to
	init_input_buffer.  Don't set or reference cpp_buffer->fname,
	use buffer->ihash->name instead.
	* cpphash.c (special_symbol): Use cpp_file_buffer.  Use NULL
	not CPP_NULL_BUFFER.
	* cppinit.c: Use NULL not CPP_NULL_BUFFER, IF_STACK not
	IF_STACK_FRAME, IHASH not struct include_hash.
	* cpplib.c: Rename eval_if_expression to eval_if_expr.  Remove
	null_underflow.  Use IF_STACK not IF_STACK_FRAME, IHASH not
	struct include_hash, NULL not CPP_NULL_BUFFER.  Remove all
	references to cpp_buffer->fname (delete entirely, or use
	->ihash->name instead) and IF_STACK->fname.
	(cpp_push_buffer): Don't set new->underflow.
	(do_include): Use cpp_file_buffer.

	* cpphash.c (collect_formal_parameters): Remove duplicate
	increment of argslen.  Pedwarn in C99 mode if __VA_ARGS__ is
	used as a macro argument name.  Don't append "..." to namebuf
	for varargs macros.  After we're done scanning, go through
	namebuf and make it NUL separated, not comma separated.
	(_cpp_compare_defs): Remove register tag from variables.
	Expect defn->argnames to be NUL separated.
	(_cpp_dump_definition): Expect defn->argnames to be NUL
	separated and in forward order.
	* cpphash.h: Update documentation of argnames field.

From-SVN: r32430
parent dd05e4fa
2000-03-08 Zack Weinberg <zack@wolery.cumb.org>
* cpplib.h (parse_underflow_t, CPP_NULL_BUFFER): Delete.
(struct cpp_buffer): Remove fname and underflow fields.
(struct cpp_reader): Remove get_token field.
(struct include_hash): Rename to struct ihash. Add typedef to
IHASH.
(struct if_stack): Remove fname field.
(IF_STACK_FRAME): Rename to IF_STACK.
* cpperror.c (print_containing_files): Trust that there are no
macro buffers below the top file buffer.
* cppfiles.c: Replace all references to 'struct include_hash'
with 'IHASH'. Rename initialize_input_buffer to
init_input_buffer. Don't set or reference cpp_buffer->fname,
use buffer->ihash->name instead.
* cpphash.c (special_symbol): Use cpp_file_buffer. Use NULL
not CPP_NULL_BUFFER.
* cppinit.c: Use NULL not CPP_NULL_BUFFER, IF_STACK not
IF_STACK_FRAME, IHASH not struct include_hash.
* cpplib.c: Rename eval_if_expression to eval_if_expr. Remove
null_underflow. Use IF_STACK not IF_STACK_FRAME, IHASH not
struct include_hash, NULL not CPP_NULL_BUFFER. Remove all
references to cpp_buffer->fname (delete entirely, or use
->ihash->name instead) and IF_STACK->fname.
(cpp_push_buffer): Don't set new->underflow.
(do_include): Use cpp_file_buffer.
* cpphash.c (collect_formal_parameters): Remove duplicate
increment of argslen. Pedwarn in C99 mode if __VA_ARGS__ is
used as a macro argument name. Don't append "..." to namebuf
for varargs macros. After we're done scanning, go through
namebuf and make it NUL separated, not comma separated.
(_cpp_compare_defs): Remove register tag from variables.
Expect defn->argnames to be NUL separated.
(_cpp_dump_definition): Expect defn->argnames to be NUL
separated and in forward order.
* cpphash.h: Update documentation of argnames field.
2000-03-08 Richard Henderson <rth@cygnus.com> 2000-03-08 Richard Henderson <rth@cygnus.com>
* builtins.c (expand_builtin_strlen): Be prepared for strlensi * builtins.c (expand_builtin_strlen): Be prepared for strlensi
......
...@@ -50,34 +50,31 @@ print_containing_files (pfile, ip) ...@@ -50,34 +50,31 @@ print_containing_files (pfile, ip)
return; return;
/* Find the other, outer source files. */ /* Find the other, outer source files. */
for (ip = CPP_PREV_BUFFER (ip); for (ip = CPP_PREV_BUFFER (ip); ip != NULL; ip = CPP_PREV_BUFFER (ip))
ip != CPP_NULL_BUFFER (pfile); {
ip = CPP_PREV_BUFFER (ip)) long line;
if (ip->fname != NULL) cpp_buf_line_and_col (ip, &line, NULL);
{ if (first)
long line; {
cpp_buf_line_and_col (ip, &line, NULL); first = 0;
if (first) fprintf (stderr, _("In file included from %s:%ld"),
{
first = 0;
fprintf (stderr, _("In file included from %s:%ld"),
ip->nominal_fname, line);
}
else
/* Translators note: this message is used in conjunction
with "In file included from %s:%ld" and some other
tricks. We want something like this:
In file included from sys/select.h:123,
from sys/types.h:234,
from userfile.c:31:
bits/select.h:45: <error message here>
The trailing comma is at the beginning of this message,
and the trailing colon is not translated. */
fprintf (stderr, _(",\n from %s:%ld"),
ip->nominal_fname, line); ip->nominal_fname, line);
} }
else
/* Translators note: this message is used in conjunction
with "In file included from %s:%ld" and some other
tricks. We want something like this:
In file included from sys/select.h:123,
from sys/types.h:234,
from userfile.c:31:
bits/select.h:45: <error message here>
The trailing comma is at the beginning of this message,
and the trailing colon is not translated. */
fprintf (stderr, _(",\n from %s:%ld"),
ip->nominal_fname, line);
}
if (first == 0) if (first == 0)
fputs (":\n", stderr); fputs (":\n", stderr);
......
...@@ -29,26 +29,21 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -29,26 +29,21 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "cpplib.h" #include "cpplib.h"
#include "intl.h" #include "intl.h"
static struct include_hash *include_hash PARAMS ((cpp_reader *, static IHASH *include_hash PARAMS ((cpp_reader *, const char *, int));
const char *, int)); static IHASH *redundant_include_p PARAMS ((cpp_reader *, IHASH *,
static struct include_hash *redundant_include_p struct file_name_list *));
PARAMS ((cpp_reader *,
struct include_hash *,
struct file_name_list *));
static struct file_name_map *read_name_map static struct file_name_map *read_name_map
PARAMS ((cpp_reader *, const char *)); PARAMS ((cpp_reader *, const char *));
static char *read_filename_string PARAMS ((int, FILE *)); static char *read_filename_string PARAMS ((int, FILE *));
static char *remap_filename PARAMS ((cpp_reader *, char *, static char *remap_filename PARAMS ((cpp_reader *, char *,
struct file_name_list *)); struct file_name_list *));
static long read_and_prescan PARAMS ((cpp_reader *, cpp_buffer *, static long read_and_prescan PARAMS ((cpp_reader *, cpp_buffer *,
int, size_t)); int, size_t));
static struct file_name_list *actual_directory static struct file_name_list *actual_directory
PARAMS ((cpp_reader *, const char *)); PARAMS ((cpp_reader *, const char *));
static void initialize_input_buffer PARAMS ((cpp_reader *, int, static void init_input_buffer PARAMS ((cpp_reader *, int, struct stat *));
struct stat *)); static int file_cleanup PARAMS ((cpp_buffer *, cpp_reader *));
static int file_cleanup PARAMS ((cpp_buffer *, cpp_reader *)); static U_CHAR *find_position PARAMS ((U_CHAR *, U_CHAR *, unsigned long *));
static U_CHAR *find_position PARAMS ((U_CHAR *, U_CHAR *,
unsigned long *));
#if 0 #if 0
static void hack_vms_include_specification PARAMS ((char *)); static void hack_vms_include_specification PARAMS ((char *));
...@@ -205,14 +200,14 @@ _cpp_merge_include_chains (opts) ...@@ -205,14 +200,14 @@ _cpp_merge_include_chains (opts)
#include name (there are at least three ways this can happen). The #include name (there are at least three ways this can happen). The
hash function could probably be improved a bit. */ hash function could probably be improved a bit. */
static struct include_hash * static IHASH *
include_hash (pfile, fname, add) include_hash (pfile, fname, add)
cpp_reader *pfile; cpp_reader *pfile;
const char *fname; const char *fname;
int add; int add;
{ {
unsigned int hash = 0; unsigned int hash = 0;
struct include_hash *l, *m; IHASH *l, *m;
const char *f = fname; const char *f = fname;
while (*f) while (*f)
...@@ -227,7 +222,7 @@ include_hash (pfile, fname, add) ...@@ -227,7 +222,7 @@ include_hash (pfile, fname, add)
if (!add) if (!add)
return 0; return 0;
l = (struct include_hash *) xmalloc (sizeof (struct include_hash)); l = (IHASH *) xmalloc (sizeof (IHASH));
l->next = NULL; l->next = NULL;
l->next_this_file = NULL; l->next_this_file = NULL;
l->foundhere = NULL; l->foundhere = NULL;
...@@ -263,14 +258,14 @@ include_hash (pfile, fname, add) ...@@ -263,14 +258,14 @@ include_hash (pfile, fname, add)
so the test below (i->foundhere == l) may be false even when so the test below (i->foundhere == l) may be false even when
the directories are in fact the same. */ the directories are in fact the same. */
static struct include_hash * static IHASH *
redundant_include_p (pfile, ihash, ilist) redundant_include_p (pfile, ihash, ilist)
cpp_reader *pfile; cpp_reader *pfile;
struct include_hash *ihash; IHASH *ihash;
struct file_name_list *ilist; struct file_name_list *ilist;
{ {
struct file_name_list *l; struct file_name_list *l;
struct include_hash *i; IHASH *i;
if (! ihash->foundhere) if (! ihash->foundhere)
return 0; return 0;
...@@ -285,7 +280,7 @@ redundant_include_p (pfile, ihash, ilist) ...@@ -285,7 +280,7 @@ redundant_include_p (pfile, ihash, ilist)
return (i->control_macro return (i->control_macro
&& (i->control_macro[0] == '\0' && (i->control_macro[0] == '\0'
|| cpp_defined (pfile, i->control_macro, -1))) || cpp_defined (pfile, i->control_macro, -1)))
? (struct include_hash *)-1 : i; ? (IHASH *)-1 : i;
return 0; return 0;
} }
...@@ -297,7 +292,7 @@ cpp_included (pfile, fname) ...@@ -297,7 +292,7 @@ cpp_included (pfile, fname)
cpp_reader *pfile; cpp_reader *pfile;
const char *fname; const char *fname;
{ {
struct include_hash *ptr; IHASH *ptr;
ptr = include_hash (pfile, fname, 0); ptr = include_hash (pfile, fname, 0);
return (ptr != NULL); return (ptr != NULL);
...@@ -330,11 +325,11 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before) ...@@ -330,11 +325,11 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before)
cpp_reader *pfile; cpp_reader *pfile;
const char *fname; const char *fname;
struct file_name_list *search_start; struct file_name_list *search_start;
struct include_hash **ihash; IHASH **ihash;
int *before; int *before;
{ {
struct file_name_list *l; struct file_name_list *l;
struct include_hash *ih, *jh; IHASH *ih, *jh;
int f, len; int f, len;
char *name; char *name;
...@@ -347,7 +342,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before) ...@@ -347,7 +342,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before)
*before = 1; *before = 1;
*ihash = jh; *ihash = jh;
if (jh == (struct include_hash *)-1) if (jh == (IHASH *)-1)
return -2; return -2;
else else
return open (jh->name, O_RDONLY, 0666); return open (jh->name, O_RDONLY, 0666);
...@@ -358,7 +353,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before) ...@@ -358,7 +353,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before)
Allocate another include_hash block and add it to the next_this_file Allocate another include_hash block and add it to the next_this_file
chain. */ chain. */
{ {
jh = (struct include_hash *)xmalloc (sizeof (struct include_hash)); jh = (IHASH *) xmalloc (sizeof (IHASH));
while (ih->next_this_file) ih = ih->next_this_file; while (ih->next_this_file) ih = ih->next_this_file;
ih->next_this_file = jh; ih->next_this_file = jh;
...@@ -422,7 +417,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before) ...@@ -422,7 +417,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before)
free (ih); free (ih);
} }
free (name); free (name);
*ihash = (struct include_hash *)-1; *ihash = (IHASH *)-1;
return -1; return -1;
} }
...@@ -627,7 +622,7 @@ cpp_read_file (pfile, fname) ...@@ -627,7 +622,7 @@ cpp_read_file (pfile, fname)
cpp_reader *pfile; cpp_reader *pfile;
const char *fname; const char *fname;
{ {
struct include_hash *ih_fake; IHASH *ih_fake;
int f; int f;
if (fname == NULL || *fname == 0) if (fname == NULL || *fname == 0)
...@@ -655,7 +650,7 @@ cpp_read_file (pfile, fname) ...@@ -655,7 +650,7 @@ cpp_read_file (pfile, fname)
/* Gin up an include_hash structure for this file and feed it /* Gin up an include_hash structure for this file and feed it
to finclude. */ to finclude. */
ih_fake = (struct include_hash *) xmalloc (sizeof (struct include_hash)); ih_fake = (IHASH *) xmalloc (sizeof (IHASH));
ih_fake->next = 0; ih_fake->next = 0;
ih_fake->next_this_file = 0; ih_fake->next_this_file = 0;
ih_fake->foundhere = ABSOLUTE_PATH; /* well sort of ... */ ih_fake->foundhere = ABSOLUTE_PATH; /* well sort of ... */
...@@ -687,7 +682,7 @@ int ...@@ -687,7 +682,7 @@ int
_cpp_read_include_file (pfile, fd, ihash) _cpp_read_include_file (pfile, fd, ihash)
cpp_reader *pfile; cpp_reader *pfile;
int fd; int fd;
struct include_hash *ihash; IHASH *ihash;
{ {
struct stat st; struct stat st;
size_t st_size; size_t st_size;
...@@ -749,12 +744,12 @@ _cpp_read_include_file (pfile, fd, ihash) ...@@ -749,12 +744,12 @@ _cpp_read_include_file (pfile, fd, ihash)
} }
if (pfile->input_buffer == NULL) if (pfile->input_buffer == NULL)
initialize_input_buffer (pfile, fd, &st); init_input_buffer (pfile, fd, &st);
/* Read the file, converting end-of-line characters and trigraphs /* Read the file, converting end-of-line characters and trigraphs
(if enabled). */ (if enabled). */
fp->ihash = ihash; fp->ihash = ihash;
fp->nominal_fname = fp->fname = ihash->name; fp->nominal_fname = ihash->name;
length = read_and_prescan (pfile, fp, fd, st_size); length = read_and_prescan (pfile, fp, fd, st_size);
if (length < 0) if (length < 0)
goto fail; goto fail;
...@@ -774,7 +769,7 @@ _cpp_read_include_file (pfile, fd, ihash) ...@@ -774,7 +769,7 @@ _cpp_read_include_file (pfile, fd, ihash)
/* The ->actual_dir field is only used when ignore_srcdir is not in effect; /* The ->actual_dir field is only used when ignore_srcdir is not in effect;
see do_include */ see do_include */
if (!CPP_OPTIONS (pfile)->ignore_srcdir) if (!CPP_OPTIONS (pfile)->ignore_srcdir)
fp->actual_dir = actual_directory (pfile, fp->fname); fp->actual_dir = actual_directory (pfile, ihash->name);
pfile->input_stack_listing_current = 0; pfile->input_stack_listing_current = 0;
return 1; return 1;
...@@ -1176,7 +1171,7 @@ read_and_prescan (pfile, fp, desc, len) ...@@ -1176,7 +1171,7 @@ read_and_prescan (pfile, fp, desc, len)
return -1; return -1;
error: error:
cpp_error_from_errno (pfile, fp->fname); cpp_error_from_errno (pfile, fp->ihash->name);
free (buf); free (buf);
return -1; return -1;
} }
...@@ -1187,7 +1182,7 @@ read_and_prescan (pfile, fp, desc, len) ...@@ -1187,7 +1182,7 @@ read_and_prescan (pfile, fp, desc, len)
the duration of the cpp run. */ the duration of the cpp run. */
static void static void
initialize_input_buffer (pfile, fd, st) init_input_buffer (pfile, fd, st)
cpp_reader *pfile; cpp_reader *pfile;
int fd; int fd;
struct stat *st; struct stat *st;
......
...@@ -548,7 +548,7 @@ collect_formal_parameters (pfile) ...@@ -548,7 +548,7 @@ collect_formal_parameters (pfile)
{ {
struct arglist *result = 0; struct arglist *result = 0;
struct arg *argv = 0; struct arg *argv = 0;
U_CHAR *namebuf = xstrdup (""); U_CHAR *namebuf = (U_CHAR *) xstrdup ("");
U_CHAR *name, *tok; U_CHAR *name, *tok;
size_t argslen = 1; size_t argslen = 1;
...@@ -587,6 +587,10 @@ collect_formal_parameters (pfile) ...@@ -587,6 +587,10 @@ collect_formal_parameters (pfile)
cpp_error (pfile, "duplicate macro argument name `%s'", tok); cpp_error (pfile, "duplicate macro argument name `%s'", tok);
continue; continue;
} }
if (CPP_PEDANTIC (pfile) && CPP_OPTIONS (pfile)->c99
&& strncmp (tok, "__VA_ARGS__", sizeof "__VA_ARGS__" - 1))
cpp_pedwarn (pfile,
"C99 does not permit use of `__VA_ARGS__' as a macro argument name");
namebuf = xrealloc (namebuf, argslen + len + 1); namebuf = xrealloc (namebuf, argslen + len + 1);
name = &namebuf[argslen - 1]; name = &namebuf[argslen - 1];
argslen += len + 1; argslen += len + 1;
...@@ -637,8 +641,6 @@ collect_formal_parameters (pfile) ...@@ -637,8 +641,6 @@ collect_formal_parameters (pfile)
name = &namebuf[argslen - 1]; name = &namebuf[argslen - 1];
argslen += len; argslen += len;
memcpy (name, "__VA_ARGS__", len); memcpy (name, "__VA_ARGS__", len);
argslen += len + 1;
argv[argc].len = len; argv[argc].len = len;
} }
else else
...@@ -646,9 +648,6 @@ collect_formal_parameters (pfile) ...@@ -646,9 +648,6 @@ collect_formal_parameters (pfile)
cpp_pedwarn (pfile, "ISO C does not permit named varargs macros"); cpp_pedwarn (pfile, "ISO C does not permit named varargs macros");
argv[argc].rest_arg = 1; argv[argc].rest_arg = 1;
namebuf = xrealloc (namebuf, argslen + 3);
memcpy (&namebuf[argslen - 1], "...", 4);
argslen += 3;
token = get_directive_token (pfile); token = get_directive_token (pfile);
if (token != CPP_RPAREN) if (token != CPP_RPAREN)
...@@ -664,6 +663,7 @@ collect_formal_parameters (pfile) ...@@ -664,6 +663,7 @@ collect_formal_parameters (pfile)
{ {
argv[i].name = namebuf + len; argv[i].name = namebuf + len;
len += argv[i].len + 1; len += argv[i].len + 1;
namebuf[len - 1] = '\0';
} }
CPP_SET_WRITTEN (pfile, old_written); CPP_SET_WRITTEN (pfile, old_written);
...@@ -834,16 +834,10 @@ special_symbol (hp, pfile) ...@@ -834,16 +834,10 @@ special_symbol (hp, pfile)
case T_FILE: case T_FILE:
case T_BASE_FILE: case T_BASE_FILE:
{ {
ip = CPP_BUFFER (pfile); ip = cpp_file_buffer (pfile);
if (hp->type == T_BASE_FILE) if (hp->type == T_BASE_FILE)
{ {
while (CPP_PREV_BUFFER (ip) != CPP_NULL_BUFFER (pfile)) while (CPP_PREV_BUFFER (ip) != NULL)
ip = CPP_PREV_BUFFER (ip);
}
else
{
ip = CPP_BUFFER (pfile);
while (!ip->nominal_fname && ip != CPP_NULL_BUFFER (pfile))
ip = CPP_PREV_BUFFER (ip); ip = CPP_PREV_BUFFER (ip);
} }
...@@ -858,11 +852,10 @@ special_symbol (hp, pfile) ...@@ -858,11 +852,10 @@ special_symbol (hp, pfile)
case T_INCLUDE_LEVEL: case T_INCLUDE_LEVEL:
{ {
int true_indepth = 0; int true_indepth = 1;
ip = CPP_BUFFER (pfile); ip = cpp_file_buffer (pfile);
for (; ip != CPP_NULL_BUFFER (pfile); ip = CPP_PREV_BUFFER (ip)) while ((ip = CPP_PREV_BUFFER (ip)) != NULL)
if (ip->fname != NULL) true_indepth++;
true_indepth++;
CPP_RESERVE (pfile, 10); CPP_RESERVE (pfile, 10);
sprintf (CPP_PWRITTEN (pfile), "%d", true_indepth); sprintf (CPP_PWRITTEN (pfile), "%d", true_indepth);
...@@ -895,9 +888,7 @@ special_symbol (hp, pfile) ...@@ -895,9 +888,7 @@ special_symbol (hp, pfile)
case T_STDC: case T_STDC:
CPP_RESERVE (pfile, 2); CPP_RESERVE (pfile, 2);
#ifdef STDC_0_IN_SYSTEM_HEADERS #ifdef STDC_0_IN_SYSTEM_HEADERS
ip = CPP_BUFFER (pfile); ip = cpp_file_buffer (pfile);
while (!ip->nominal_fname && ip != CPP_NULL_BUFFER (pfile))
ip = CPP_PREV_BUFFER (ip);
if (ip->system_header_p if (ip->system_header_p
&& !cpp_defined (pfile, (const U_CHAR *) "__STRICT_ANSI__", 15)) && !cpp_defined (pfile, (const U_CHAR *) "__STRICT_ANSI__", 15))
CPP_PUTC_Q (pfile, '0'); CPP_PUTC_Q (pfile, '0');
...@@ -1488,17 +1479,29 @@ _cpp_compare_defs (pfile, d1, d2) ...@@ -1488,17 +1479,29 @@ _cpp_compare_defs (pfile, d1, d2)
cpp_reader *pfile; cpp_reader *pfile;
DEFINITION *d1, *d2; DEFINITION *d1, *d2;
{ {
register struct reflist *a1, *a2; struct reflist *a1, *a2;
register U_CHAR *p1 = d1->expansion; U_CHAR *p1 = d1->expansion;
register U_CHAR *p2 = d2->expansion; U_CHAR *p2 = d2->expansion;
int first = 1; int first = 1;
if (d1->nargs != d2->nargs) if (d1->nargs != d2->nargs)
return 1; return 1;
if (CPP_PEDANTIC (pfile) if (CPP_PEDANTIC (pfile)
&& d1->argnames && d2->argnames && d1->argnames && d2->argnames)
&& strcmp ((char *) d1->argnames, (char *) d2->argnames)) {
return 1; U_CHAR *arg1 = d1->argnames;
U_CHAR *arg2 = d2->argnames;
size_t len;
int i = d1->nargs;
while (i--)
{
len = strlen (arg1);
if (strcmp (arg1, arg2))
return 1;
arg1 += len;
arg2 += len;
}
}
for (a1 = d1->pattern, a2 = d2->pattern; a1 && a2; for (a1 = d1->pattern, a2 = d2->pattern; a1 && a2;
a1 = a1->next, a2 = a2->next) a1 = a1->next, a2 = a2->next)
{ {
...@@ -1602,7 +1605,6 @@ _cpp_dump_definition (pfile, sym, len, defn) ...@@ -1602,7 +1605,6 @@ _cpp_dump_definition (pfile, sym, len, defn)
else else
{ {
struct reflist *r; struct reflist *r;
unsigned char *argnames = (unsigned char *) xstrdup (defn->argnames);
unsigned char **argv = (unsigned char **) alloca (defn->nargs * unsigned char **argv = (unsigned char **) alloca (defn->nargs *
sizeof(char *)); sizeof(char *));
int *argl = (int *) alloca (defn->nargs * sizeof(int)); int *argl = (int *) alloca (defn->nargs * sizeof(int));
...@@ -1610,18 +1612,12 @@ _cpp_dump_definition (pfile, sym, len, defn) ...@@ -1610,18 +1612,12 @@ _cpp_dump_definition (pfile, sym, len, defn)
int i; int i;
/* First extract the argument list. */ /* First extract the argument list. */
x = argnames; x = defn->argnames;
i = defn->nargs; for (i = 0; i < defn->nargs; i++)
while (i--)
{ {
argv[i] = x; argv[i] = x;
while (*x != ',' && *x != '\0') x++; argl[i] = strlen (x);
argl[i] = x - argv[i]; x += argl[i] + 1;
if (*x == ',')
{
*x = '\0';
x += 2; /* skip the space after the comma */
}
} }
/* Now print out the argument list. */ /* Now print out the argument list. */
...@@ -1629,15 +1625,15 @@ _cpp_dump_definition (pfile, sym, len, defn) ...@@ -1629,15 +1625,15 @@ _cpp_dump_definition (pfile, sym, len, defn)
for (i = 0; i < defn->nargs; i++) for (i = 0; i < defn->nargs; i++)
{ {
CPP_RESERVE (pfile, argl[i] + 2); CPP_RESERVE (pfile, argl[i] + 2);
CPP_PUTS_Q (pfile, argv[i], argl[i]); if (!(i == defn->nargs-1 && defn->rest_args
&& !strcmp (argv[i], "__VA_ARGS__")))
CPP_PUTS_Q (pfile, argv[i], argl[i]);
if (i < defn->nargs-1) if (i < defn->nargs-1)
CPP_PUTS_Q (pfile, ", ", 2); CPP_PUTS_Q (pfile, ", ", 2);
} }
if (defn->rest_args) if (defn->rest_args)
CPP_PUTS (pfile, "...) ", 5); CPP_PUTS (pfile, "...", 3);
else CPP_PUTS (pfile, ") ", 2);
CPP_PUTS (pfile, ") ", 2);
/* Now the definition. */ /* Now the definition. */
x = defn->expansion; x = defn->expansion;
......
...@@ -64,7 +64,7 @@ struct definition ...@@ -64,7 +64,7 @@ struct definition
char rest_args; /* Nonzero if last arg. absorbs the rest */ char rest_args; /* Nonzero if last arg. absorbs the rest */
struct reflist *pattern; struct reflist *pattern;
/* Names of macro args, concatenated in order with commas between /* Names of macro args, concatenated in order with \0 between
them. The only use of this is that we warn on redefinition if them. The only use of this is that we warn on redefinition if
this differs between the old and new definitions. */ this differs between the old and new definitions. */
U_CHAR *argnames; U_CHAR *argnames;
......
...@@ -398,7 +398,7 @@ cpp_cleanup (pfile) ...@@ -398,7 +398,7 @@ cpp_cleanup (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
int i; int i;
while (CPP_BUFFER (pfile) != CPP_NULL_BUFFER (pfile)) while (CPP_BUFFER (pfile) != NULL)
cpp_pop_buffer (pfile); cpp_pop_buffer (pfile);
if (pfile->token_buffer) if (pfile->token_buffer)
...@@ -420,22 +420,20 @@ cpp_cleanup (pfile) ...@@ -420,22 +420,20 @@ cpp_cleanup (pfile)
while (pfile->if_stack) while (pfile->if_stack)
{ {
IF_STACK_FRAME *temp = pfile->if_stack; IF_STACK *temp = pfile->if_stack;
pfile->if_stack = temp->next; pfile->if_stack = temp->next;
free (temp); free (temp);
} }
for (i = ALL_INCLUDE_HASHSIZE; --i >= 0; ) for (i = ALL_INCLUDE_HASHSIZE; --i >= 0; )
{ {
struct include_hash *imp = pfile->all_include_files[i]; IHASH *imp, *next;
while (imp) for (imp = pfile->all_include_files[i]; imp; imp = next)
{ {
struct include_hash *next = imp->next; next = imp->next;
free ((PTR) imp->name); free ((PTR) imp->name);
free ((PTR) imp->nshort); free ((PTR) imp->nshort);
free (imp); free (imp);
imp = next;
} }
pfile->all_include_files[i] = 0; pfile->all_include_files[i] = 0;
} }
...@@ -846,7 +844,7 @@ cpp_finish (pfile) ...@@ -846,7 +844,7 @@ cpp_finish (pfile)
{ {
struct cpp_options *opts = CPP_OPTIONS (pfile); struct cpp_options *opts = CPP_OPTIONS (pfile);
if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) != CPP_NULL_BUFFER (pfile)) if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) != NULL)
cpp_ice (pfile, "buffers still stacked in cpp_finish"); cpp_ice (pfile, "buffers still stacked in cpp_finish");
cpp_pop_buffer (pfile); cpp_pop_buffer (pfile);
......
...@@ -61,7 +61,6 @@ enum cpp_token ...@@ -61,7 +61,6 @@ enum cpp_token
CPP_POP /* We're about to pop the buffer stack. */ CPP_POP /* We're about to pop the buffer stack. */
}; };
typedef enum cpp_token (*parse_underflow_t) PARAMS((cpp_reader *));
typedef int (*parse_cleanup_t) PARAMS((cpp_buffer *, cpp_reader *)); typedef int (*parse_cleanup_t) PARAMS((cpp_buffer *, cpp_reader *));
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **)); extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
...@@ -82,8 +81,6 @@ struct cpp_buffer ...@@ -82,8 +81,6 @@ struct cpp_buffer
struct cpp_buffer *prev; struct cpp_buffer *prev;
/* Real filename. (Alias to ->ihash->fname, obsolete). */
const char *fname;
/* Filename specified with #line command. */ /* Filename specified with #line command. */
const char *nominal_fname; const char *nominal_fname;
/* Last filename specified with #line command. */ /* Last filename specified with #line command. */
...@@ -93,12 +90,11 @@ struct cpp_buffer ...@@ -93,12 +90,11 @@ struct cpp_buffer
/* Pointer into the include hash table. Used for include_next and /* Pointer into the include hash table. Used for include_next and
to record control macros. */ to record control macros. */
struct include_hash *ihash; struct ihash *ihash;
long lineno; /* Line number at CPP_LINE_BASE. */ long lineno; /* Line number at CPP_LINE_BASE. */
long colno; /* Column number at CPP_LINE_BASE. */ long colno; /* Column number at CPP_LINE_BASE. */
long mark; /* Saved position for lengthy backtrack. */ long mark; /* Saved position for lengthy backtrack. */
parse_underflow_t underflow;
parse_cleanup_t cleanup; parse_cleanup_t cleanup;
void *data; void *data;
...@@ -146,7 +142,6 @@ struct file_name_map_list; ...@@ -146,7 +142,6 @@ struct file_name_map_list;
struct cpp_reader struct cpp_reader
{ {
parse_underflow_t get_token;
cpp_buffer *buffer; cpp_buffer *buffer;
cpp_options *opts; cpp_options *opts;
...@@ -175,7 +170,7 @@ struct cpp_reader ...@@ -175,7 +170,7 @@ struct cpp_reader
/* Hash table of other included files. See cppfiles.c */ /* Hash table of other included files. See cppfiles.c */
#define ALL_INCLUDE_HASHSIZE 71 #define ALL_INCLUDE_HASHSIZE 71
struct include_hash *all_include_files[ALL_INCLUDE_HASHSIZE]; struct ihash *all_include_files[ALL_INCLUDE_HASHSIZE];
/* Chain of `actual directory' file_name_list entries, /* Chain of `actual directory' file_name_list entries,
for "" inclusion. */ for "" inclusion. */
...@@ -284,8 +279,6 @@ struct cpp_reader ...@@ -284,8 +279,6 @@ struct cpp_reader
#define CPP_OPTIONS(PFILE) ((PFILE)->opts) #define CPP_OPTIONS(PFILE) ((PFILE)->opts)
#define CPP_BUFFER(PFILE) ((PFILE)->buffer) #define CPP_BUFFER(PFILE) ((PFILE)->buffer)
#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->prev) #define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->prev)
/* The bottom of the buffer stack. */
#define CPP_NULL_BUFFER(PFILE) NULL
/* The `pending' structure accumulates all the options that are not /* The `pending' structure accumulates all the options that are not
actually processed until we hit cpp_start_read. It consists of actually processed until we hit cpp_start_read. It consists of
...@@ -528,12 +521,12 @@ struct file_name_list ...@@ -528,12 +521,12 @@ struct file_name_list
/* This structure is used for the table of all includes. It is /* This structure is used for the table of all includes. It is
indexed by the `short name' (the name as it appeared in the indexed by the `short name' (the name as it appeared in the
#include statement) which is stored in *nshort. */ #include statement) which is stored in *nshort. */
struct include_hash struct ihash
{ {
struct include_hash *next; struct ihash *next;
/* Next file with the same short name but a /* Next file with the same short name but a
different (partial) pathname). */ different (partial) pathname). */
struct include_hash *next_this_file; struct ihash *next_this_file;
/* Location of the file in the include search path. /* Location of the file in the include search path.
Used for include_next */ Used for include_next */
...@@ -545,6 +538,7 @@ struct include_hash ...@@ -545,6 +538,7 @@ struct include_hash
char *buf, *limit; /* for file content cache, char *buf, *limit; /* for file content cache,
not yet implemented */ not yet implemented */
}; };
typedef struct ihash IHASH;
/* Name under which this program was invoked. */ /* Name under which this program was invoked. */
...@@ -623,17 +617,15 @@ extern unsigned char _cpp_IStable[256]; ...@@ -623,17 +617,15 @@ extern unsigned char _cpp_IStable[256];
/* Stack of conditionals currently in progress /* Stack of conditionals currently in progress
(including both successful and failing conditionals). */ (including both successful and failing conditionals). */
struct if_stack { struct if_stack
struct if_stack *next; /* for chaining to the next stack frame */ {
const char *fname; /* copied from input when frame is made */ struct if_stack *next;
int lineno; /* similarly */ int lineno; /* line number where condition started */
int if_succeeded; /* true if a leg of this if-group int if_succeeded; /* truth of last condition in this group */
has been passed through rescan */ const U_CHAR *control_macro; /* macro name for #ifndef around entire file */
U_CHAR *control_macro; /* For #ifndef at start of file,
this is the macro name tested. */
enum node_type type; /* type of last directive seen in this group */ enum node_type type; /* type of last directive seen in this group */
}; };
typedef struct if_stack IF_STACK_FRAME; typedef struct if_stack IF_STACK;
extern void cpp_buf_line_and_col PARAMS((cpp_buffer *, long *, long *)); extern void cpp_buf_line_and_col PARAMS((cpp_buffer *, long *, long *));
extern cpp_buffer *cpp_file_buffer PARAMS((cpp_reader *)); extern cpp_buffer *cpp_file_buffer PARAMS((cpp_reader *));
...@@ -700,10 +692,8 @@ extern void _cpp_simplify_pathname PARAMS ((char *)); ...@@ -700,10 +692,8 @@ extern void _cpp_simplify_pathname PARAMS ((char *));
extern void _cpp_merge_include_chains PARAMS ((struct cpp_options *)); extern void _cpp_merge_include_chains PARAMS ((struct cpp_options *));
extern int _cpp_find_include_file PARAMS ((cpp_reader *, const char *, extern int _cpp_find_include_file PARAMS ((cpp_reader *, const char *,
struct file_name_list *, struct file_name_list *,
struct include_hash **, IHASH **, int *));
int *)); extern int _cpp_read_include_file PARAMS ((cpp_reader *, int, IHASH *));
extern int _cpp_read_include_file PARAMS ((cpp_reader *, int,
struct include_hash *));
/* In cppexp.c */ /* In cppexp.c */
extern HOST_WIDEST_INT _cpp_parse_expr PARAMS ((cpp_reader *)); extern HOST_WIDEST_INT _cpp_parse_expr PARAMS ((cpp_reader *));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment