* 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
+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>
* builtins.c (expand_builtin_strlen): Be prepared for strlensi
return;
/* Find the other, outer source files. */
- for (ip = CPP_PREV_BUFFER (ip);
- ip != CPP_NULL_BUFFER (pfile);
- ip = CPP_PREV_BUFFER (ip))
- if (ip->fname != NULL)
- {
- long line;
- cpp_buf_line_and_col (ip, &line, NULL);
- if (first)
- {
- 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"),
+ for (ip = CPP_PREV_BUFFER (ip); ip != NULL; ip = CPP_PREV_BUFFER (ip))
+ {
+ long line;
+ cpp_buf_line_and_col (ip, &line, NULL);
+ if (first)
+ {
+ 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);
+ }
if (first == 0)
fputs (":\n", stderr);
#include "cpplib.h"
#include "intl.h"
-static struct include_hash *include_hash PARAMS ((cpp_reader *,
- const char *, int));
-static struct include_hash *redundant_include_p
- PARAMS ((cpp_reader *,
- struct include_hash *,
- struct file_name_list *));
+static IHASH *include_hash PARAMS ((cpp_reader *, const char *, int));
+static IHASH *redundant_include_p PARAMS ((cpp_reader *, IHASH *,
+ struct file_name_list *));
static struct file_name_map *read_name_map
- PARAMS ((cpp_reader *, const char *));
-static char *read_filename_string PARAMS ((int, FILE *));
-static char *remap_filename PARAMS ((cpp_reader *, char *,
- struct file_name_list *));
-static long read_and_prescan PARAMS ((cpp_reader *, cpp_buffer *,
- int, size_t));
+ PARAMS ((cpp_reader *, const char *));
+static char *read_filename_string PARAMS ((int, FILE *));
+static char *remap_filename PARAMS ((cpp_reader *, char *,
+ struct file_name_list *));
+static long read_and_prescan PARAMS ((cpp_reader *, cpp_buffer *,
+ int, size_t));
static struct file_name_list *actual_directory
- PARAMS ((cpp_reader *, const char *));
-static void initialize_input_buffer PARAMS ((cpp_reader *, int,
- struct stat *));
-static int file_cleanup PARAMS ((cpp_buffer *, cpp_reader *));
-static U_CHAR *find_position PARAMS ((U_CHAR *, U_CHAR *,
- unsigned long *));
+ PARAMS ((cpp_reader *, const char *));
+static void init_input_buffer PARAMS ((cpp_reader *, int, struct stat *));
+static int file_cleanup PARAMS ((cpp_buffer *, cpp_reader *));
+static U_CHAR *find_position PARAMS ((U_CHAR *, U_CHAR *, unsigned long *));
#if 0
static void hack_vms_include_specification PARAMS ((char *));
#include name (there are at least three ways this can happen). The
hash function could probably be improved a bit. */
-static struct include_hash *
+static IHASH *
include_hash (pfile, fname, add)
cpp_reader *pfile;
const char *fname;
int add;
{
unsigned int hash = 0;
- struct include_hash *l, *m;
+ IHASH *l, *m;
const char *f = fname;
while (*f)
if (!add)
return 0;
- l = (struct include_hash *) xmalloc (sizeof (struct include_hash));
+ l = (IHASH *) xmalloc (sizeof (IHASH));
l->next = NULL;
l->next_this_file = NULL;
l->foundhere = NULL;
so the test below (i->foundhere == l) may be false even when
the directories are in fact the same. */
-static struct include_hash *
+static IHASH *
redundant_include_p (pfile, ihash, ilist)
cpp_reader *pfile;
- struct include_hash *ihash;
+ IHASH *ihash;
struct file_name_list *ilist;
{
struct file_name_list *l;
- struct include_hash *i;
+ IHASH *i;
if (! ihash->foundhere)
return 0;
return (i->control_macro
&& (i->control_macro[0] == '\0'
|| cpp_defined (pfile, i->control_macro, -1)))
- ? (struct include_hash *)-1 : i;
+ ? (IHASH *)-1 : i;
return 0;
}
cpp_reader *pfile;
const char *fname;
{
- struct include_hash *ptr;
+ IHASH *ptr;
ptr = include_hash (pfile, fname, 0);
return (ptr != NULL);
cpp_reader *pfile;
const char *fname;
struct file_name_list *search_start;
- struct include_hash **ihash;
+ IHASH **ihash;
int *before;
{
struct file_name_list *l;
- struct include_hash *ih, *jh;
+ IHASH *ih, *jh;
int f, len;
char *name;
*before = 1;
*ihash = jh;
- if (jh == (struct include_hash *)-1)
+ if (jh == (IHASH *)-1)
return -2;
else
return open (jh->name, O_RDONLY, 0666);
Allocate another include_hash block and add it to the next_this_file
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;
ih->next_this_file = jh;
free (ih);
}
free (name);
- *ihash = (struct include_hash *)-1;
+ *ihash = (IHASH *)-1;
return -1;
}
cpp_reader *pfile;
const char *fname;
{
- struct include_hash *ih_fake;
+ IHASH *ih_fake;
int f;
if (fname == NULL || *fname == 0)
/* Gin up an include_hash structure for this file and feed it
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_this_file = 0;
ih_fake->foundhere = ABSOLUTE_PATH; /* well sort of ... */
_cpp_read_include_file (pfile, fd, ihash)
cpp_reader *pfile;
int fd;
- struct include_hash *ihash;
+ IHASH *ihash;
{
struct stat st;
size_t st_size;
}
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
(if enabled). */
fp->ihash = ihash;
- fp->nominal_fname = fp->fname = ihash->name;
+ fp->nominal_fname = ihash->name;
length = read_and_prescan (pfile, fp, fd, st_size);
if (length < 0)
goto fail;
/* The ->actual_dir field is only used when ignore_srcdir is not in effect;
see do_include */
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;
return 1;
return -1;
error:
- cpp_error_from_errno (pfile, fp->fname);
+ cpp_error_from_errno (pfile, fp->ihash->name);
free (buf);
return -1;
}
the duration of the cpp run. */
static void
-initialize_input_buffer (pfile, fd, st)
+init_input_buffer (pfile, fd, st)
cpp_reader *pfile;
int fd;
struct stat *st;
{
struct arglist *result = 0;
struct arg *argv = 0;
- U_CHAR *namebuf = xstrdup ("");
+ U_CHAR *namebuf = (U_CHAR *) xstrdup ("");
U_CHAR *name, *tok;
size_t argslen = 1;
cpp_error (pfile, "duplicate macro argument name `%s'", tok);
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);
name = &namebuf[argslen - 1];
argslen += len + 1;
name = &namebuf[argslen - 1];
argslen += len;
memcpy (name, "__VA_ARGS__", len);
-
- argslen += len + 1;
argv[argc].len = len;
}
else
cpp_pedwarn (pfile, "ISO C does not permit named varargs macros");
argv[argc].rest_arg = 1;
- namebuf = xrealloc (namebuf, argslen + 3);
- memcpy (&namebuf[argslen - 1], "...", 4);
- argslen += 3;
token = get_directive_token (pfile);
if (token != CPP_RPAREN)
{
argv[i].name = namebuf + len;
len += argv[i].len + 1;
+ namebuf[len - 1] = '\0';
}
CPP_SET_WRITTEN (pfile, old_written);
case T_FILE:
case T_BASE_FILE:
{
- ip = CPP_BUFFER (pfile);
+ ip = cpp_file_buffer (pfile);
if (hp->type == T_BASE_FILE)
{
- while (CPP_PREV_BUFFER (ip) != CPP_NULL_BUFFER (pfile))
- ip = CPP_PREV_BUFFER (ip);
- }
- else
- {
- ip = CPP_BUFFER (pfile);
- while (!ip->nominal_fname && ip != CPP_NULL_BUFFER (pfile))
+ while (CPP_PREV_BUFFER (ip) != NULL)
ip = CPP_PREV_BUFFER (ip);
}
case T_INCLUDE_LEVEL:
{
- int true_indepth = 0;
- ip = CPP_BUFFER (pfile);
- for (; ip != CPP_NULL_BUFFER (pfile); ip = CPP_PREV_BUFFER (ip))
- if (ip->fname != NULL)
- true_indepth++;
+ int true_indepth = 1;
+ ip = cpp_file_buffer (pfile);
+ while ((ip = CPP_PREV_BUFFER (ip)) != NULL)
+ true_indepth++;
CPP_RESERVE (pfile, 10);
sprintf (CPP_PWRITTEN (pfile), "%d", true_indepth);
case T_STDC:
CPP_RESERVE (pfile, 2);
#ifdef STDC_0_IN_SYSTEM_HEADERS
- ip = CPP_BUFFER (pfile);
- while (!ip->nominal_fname && ip != CPP_NULL_BUFFER (pfile))
- ip = CPP_PREV_BUFFER (ip);
+ ip = cpp_file_buffer (pfile);
if (ip->system_header_p
&& !cpp_defined (pfile, (const U_CHAR *) "__STRICT_ANSI__", 15))
CPP_PUTC_Q (pfile, '0');
cpp_reader *pfile;
DEFINITION *d1, *d2;
{
- register struct reflist *a1, *a2;
- register U_CHAR *p1 = d1->expansion;
- register U_CHAR *p2 = d2->expansion;
+ struct reflist *a1, *a2;
+ U_CHAR *p1 = d1->expansion;
+ U_CHAR *p2 = d2->expansion;
int first = 1;
if (d1->nargs != d2->nargs)
return 1;
if (CPP_PEDANTIC (pfile)
- && d1->argnames && d2->argnames
- && strcmp ((char *) d1->argnames, (char *) d2->argnames))
- return 1;
+ && d1->argnames && d2->argnames)
+ {
+ 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;
a1 = a1->next, a2 = a2->next)
{
else
{
struct reflist *r;
- unsigned char *argnames = (unsigned char *) xstrdup (defn->argnames);
unsigned char **argv = (unsigned char **) alloca (defn->nargs *
sizeof(char *));
int *argl = (int *) alloca (defn->nargs * sizeof(int));
int i;
/* First extract the argument list. */
- x = argnames;
- i = defn->nargs;
- while (i--)
+ x = defn->argnames;
+ for (i = 0; i < defn->nargs; i++)
{
argv[i] = x;
- while (*x != ',' && *x != '\0') x++;
- argl[i] = x - argv[i];
- if (*x == ',')
- {
- *x = '\0';
- x += 2; /* skip the space after the comma */
- }
+ argl[i] = strlen (x);
+ x += argl[i] + 1;
}
/* Now print out the argument list. */
for (i = 0; i < defn->nargs; i++)
{
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)
CPP_PUTS_Q (pfile, ", ", 2);
}
-
if (defn->rest_args)
- CPP_PUTS (pfile, "...) ", 5);
- else
- CPP_PUTS (pfile, ") ", 2);
+ CPP_PUTS (pfile, "...", 3);
+ CPP_PUTS (pfile, ") ", 2);
/* Now the definition. */
x = defn->expansion;
char rest_args; /* Nonzero if last arg. absorbs the rest */
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
this differs between the old and new definitions. */
U_CHAR *argnames;
cpp_reader *pfile;
{
int i;
- while (CPP_BUFFER (pfile) != CPP_NULL_BUFFER (pfile))
+ while (CPP_BUFFER (pfile) != NULL)
cpp_pop_buffer (pfile);
if (pfile->token_buffer)
while (pfile->if_stack)
{
- IF_STACK_FRAME *temp = pfile->if_stack;
+ IF_STACK *temp = pfile->if_stack;
pfile->if_stack = temp->next;
free (temp);
}
for (i = ALL_INCLUDE_HASHSIZE; --i >= 0; )
{
- struct include_hash *imp = pfile->all_include_files[i];
- while (imp)
+ IHASH *imp, *next;
+ 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->nshort);
free (imp);
- imp = next;
}
pfile->all_include_files[i] = 0;
}
{
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_pop_buffer (pfile);
/* Forward declarations. */
static void validate_else PARAMS ((cpp_reader *, const char *));
-static HOST_WIDEST_INT eval_if_expression PARAMS ((cpp_reader *));
+static HOST_WIDEST_INT eval_if_expr PARAMS ((cpp_reader *));
static void conditional_skip PARAMS ((cpp_reader *, int,
enum node_type, U_CHAR *));
static void skip_if_group PARAMS ((cpp_reader *));
static int parse_assertion PARAMS ((cpp_reader *));
static const char *if_directive_name PARAMS ((cpp_reader *,
struct if_stack *));
-static enum cpp_token null_underflow PARAMS ((cpp_reader *));
static int null_cleanup PARAMS ((cpp_buffer *, cpp_reader *));
static int skip_comment PARAMS ((cpp_reader *, int));
static int copy_comment PARAMS ((cpp_reader *, int));
const struct directive *));
static int read_line_number PARAMS ((cpp_reader *, int *));
static U_CHAR *detect_if_not_defined PARAMS ((cpp_reader *));
-static int consider_directive_while_skipping PARAMS ((cpp_reader *,
- IF_STACK_FRAME *));
+static int consider_directive_while_skipping
+ PARAMS ((cpp_reader *, IF_STACK *));
static void skip_block_comment PARAMS ((cpp_reader *));
static void skip_line_comment PARAMS ((cpp_reader *));
static void parse_set_mark PARAMS ((cpp_reader *));
return (hp != NULL);
}
-static enum cpp_token
-null_underflow (pfile)
- cpp_reader *pfile ATTRIBUTE_UNUSED;
-{
- return CPP_EOF;
-}
-
static int
null_cleanup (pbuf, pfile)
cpp_buffer *pbuf ATTRIBUTE_UNUSED;
new->if_stack = pfile->if_stack;
new->cleanup = null_cleanup;
- new->underflow = null_underflow;
new->buf = new->cur = buffer;
new->alimit = new->rlimit = buffer + length;
new->prev = buf;
break;
if (token == CPP_POP && CPP_BUFFER (pfile) == buffer)
{
- if (CPP_PREV_BUFFER (CPP_BUFFER (pfile))
- != CPP_NULL_BUFFER (pfile))
+ if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) != NULL)
cpp_pop_buffer (pfile);
break;
}
break;
if (token == CPP_POP && CPP_BUFFER (pfile) == buffer)
{
- if (CPP_PREV_BUFFER (CPP_BUFFER (pfile))
- != CPP_NULL_BUFFER (pfile))
+ if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) != NULL)
cpp_pop_buffer (pfile);
break;
}
cpp_file_buffer (pfile)
cpp_reader *pfile;
{
- cpp_buffer *ip = CPP_BUFFER (pfile);
+ cpp_buffer *ip;
- for ( ; ip != CPP_NULL_BUFFER (pfile); ip = CPP_PREV_BUFFER (ip))
- if (ip->fname != NULL)
+ for (ip = CPP_BUFFER (pfile); ip; ip = CPP_PREV_BUFFER (ip))
+ if (ip->ihash != NULL)
return ip;
return NULL;
}
enum cpp_token token;
/* Chain of dirs to search */
- struct include_hash *ihash;
+ IHASH *ihash;
struct file_name_list *search_start;
long old_written = CPP_WRITTEN (pfile);
search_start = 0;
- for (fp = CPP_BUFFER (pfile);
- fp != CPP_NULL_BUFFER (pfile);
- fp = CPP_PREV_BUFFER (fp))
- if (fp->fname != NULL)
- break;
+ fp = cpp_file_buffer (pfile);
- if (fp == CPP_NULL_BUFFER (pfile))
- {
- cpp_ice (pfile, "fp == NULL_BUFFER in do_include");
- return 0;
- }
-
/* For #include_next, skip in the search path past the dir in which the
containing file was found. Treat files specified using an absolute path
as if there are no more directories to search. Treat the primary source
file like any other included source, but generate a warning. */
- if (skip_dirs && CPP_PREV_BUFFER(fp) != CPP_NULL_BUFFER (pfile))
+ if (skip_dirs && CPP_PREV_BUFFER (fp))
{
if (fp->ihash->foundhere != ABSOLUTE_PATH)
search_start = fp->ihash->foundhere->next;
if (CPP_OPTIONS(pfile)->print_include_names)
{
fp = CPP_BUFFER (pfile);
- while ((fp = CPP_PREV_BUFFER (fp)) != CPP_NULL_BUFFER (pfile))
+ while ((fp = CPP_PREV_BUFFER (fp)) != NULL)
putc ('.', stderr);
fprintf (stderr, " %s\n", ihash->name);
}
if (strcmp (fname, ip->nominal_fname))
{
const char *newname, *oldname;
- if (!strcmp (fname, ip->fname))
- newname = ip->fname;
+ if (!strcmp (fname, ip->ihash->name))
+ newname = ip->ihash->name;
else if (ip->last_nominal_fname
&& !strcmp (fname, ip->last_nominal_fname))
newname = ip->last_nominal_fname;
if (ip->last_nominal_fname
&& ip->last_nominal_fname != oldname
&& ip->last_nominal_fname != newname
- && ip->last_nominal_fname != ip->fname)
+ && ip->last_nominal_fname != ip->ihash->name)
free ((void *) ip->last_nominal_fname);
- if (newname == ip->fname)
+ if (newname == ip->ihash->name)
ip->last_nominal_fname = NULL;
else
ip->last_nominal_fname = oldname;
{
cpp_buffer *ip = CPP_BUFFER (pfile);
- if (ip->fname == NULL)
- {
- cpp_ice (pfile, "ip->fname == NULL in do_pragma_once");
- return 1;
- }
-
/* Allow #pragma once in system headers, since that's not the user's
fault. */
if (!ip->system_header_p)
cpp_warning (pfile, "`#pragma once' is obsolete");
- if (CPP_PREV_BUFFER (ip) == CPP_NULL_BUFFER (pfile))
+ if (CPP_PREV_BUFFER (ip) == NULL)
cpp_warning (pfile, "`#pragma once' outside include file");
else
ip->ihash->control_macro = ""; /* never repeat */
const struct directive *keyword ATTRIBUTE_UNUSED;
{
U_CHAR *control_macro = detect_if_not_defined (pfile);
- HOST_WIDEST_INT value = eval_if_expression (pfile);
+ HOST_WIDEST_INT value = eval_if_expr (pfile);
conditional_skip (pfile, value == 0, T_IF, control_macro);
return 0;
}
skip_if_group (pfile);
else
{
- HOST_WIDEST_INT value = eval_if_expression (pfile);
+ HOST_WIDEST_INT value = eval_if_expr (pfile);
if (value == 0)
skip_if_group (pfile);
else
*/
static HOST_WIDEST_INT
-eval_if_expression (pfile)
+eval_if_expr (pfile)
cpp_reader *pfile;
{
HOST_WIDEST_INT value;
const struct directive *keyword;
{
int skip;
- cpp_buffer *ip = CPP_BUFFER (pfile);
U_CHAR *ident;
int ident_length;
enum cpp_token token;
int old_written = CPP_WRITTEN (pfile);
/* Detect a #ifndef at start of file (not counting comments). */
- if (ip->fname != 0 && keyword->type == T_IFNDEF)
+ if (keyword->type == T_IFNDEF)
start_of_file = pfile->only_seen_white == 2;
pfile->no_macro_expand++;
enum node_type type;
U_CHAR *control_macro;
{
- IF_STACK_FRAME *temp;
+ IF_STACK *temp;
- temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME));
- temp->fname = CPP_BUFFER (pfile)->nominal_fname;
+ temp = (IF_STACK *) xcalloc (1, sizeof (IF_STACK));
temp->lineno = CPP_BUFFER (pfile)->lineno;
temp->next = pfile->if_stack;
temp->control_macro = control_macro;
static int
consider_directive_while_skipping (pfile, stack)
cpp_reader *pfile;
- IF_STACK_FRAME *stack;
+ IF_STACK *stack;
{
long ident_len, ident;
const struct directive *kt;
- IF_STACK_FRAME *temp;
+ IF_STACK *temp;
cpp_skip_hspace (pfile);
case T_IF:
case T_IFDEF:
case T_IFNDEF:
- temp = (IF_STACK_FRAME *) xmalloc (sizeof (IF_STACK_FRAME));
+ temp = (IF_STACK *) xmalloc (sizeof (IF_STACK));
temp->next = pfile->if_stack;
pfile->if_stack = temp;
- temp->fname = CPP_BUFFER(pfile)->nominal_fname;
temp->type = kt->type;
return 0;
cpp_reader *pfile;
{
int c;
- IF_STACK_FRAME *save_if_stack = pfile->if_stack; /* don't pop past here */
+ IF_STACK *save_if_stack = pfile->if_stack; /* don't pop past here */
U_CHAR *beg_of_line;
long old_written;
cpp_error (pfile, "`#endif' not within a conditional");
else
{
- IF_STACK_FRAME *temp = pfile->if_stack;
+ IF_STACK *temp = pfile->if_stack;
pfile->if_stack = temp->next;
if (temp->control_macro != 0)
{
that contains all of the file (aside from whitespace).
Arrange not to include the file again
if the macro that was tested is defined. */
- struct cpp_buffer *ip;
- for (ip = CPP_BUFFER (pfile); ; ip = CPP_PREV_BUFFER (ip))
- if (ip->fname != NULL)
- break;
- ip->ihash->control_macro = temp->control_macro;
+ CPP_BUFFER (pfile)->ihash->control_macro = temp->control_macro;
}
}
free (temp);
return CPP_EOF;
else if (CPP_BUFFER (pfile)->seen_eof)
{
- if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) == CPP_NULL_BUFFER (pfile))
+ if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) == NULL)
return CPP_EOF;
cpp_pop_buffer (pfile);
}
pfile->if_stack = ifs;
- if (CPP_BUFFER (pfile)->nominal_fname
- && next_buf != CPP_NULL_BUFFER (pfile))
+ if (CPP_BUFFER (pfile)->nominal_fname && next_buf != NULL)
{
/* We're about to return from an #include file.
Emit #line information now (as part of the CPP_POP) result.
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 *));
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
struct cpp_buffer *prev;
- /* Real filename. (Alias to ->ihash->fname, obsolete). */
- const char *fname;
/* Filename specified with #line command. */
const char *nominal_fname;
/* Last filename specified with #line command. */
/* Pointer into the include hash table. Used for include_next and
to record control macros. */
- struct include_hash *ihash;
+ struct ihash *ihash;
long lineno; /* Line number at CPP_LINE_BASE. */
long colno; /* Column number at CPP_LINE_BASE. */
long mark; /* Saved position for lengthy backtrack. */
- parse_underflow_t underflow;
parse_cleanup_t cleanup;
void *data;
struct cpp_reader
{
- parse_underflow_t get_token;
cpp_buffer *buffer;
cpp_options *opts;
/* Hash table of other included files. See cppfiles.c */
#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,
for "" inclusion. */
#define CPP_OPTIONS(PFILE) ((PFILE)->opts)
#define CPP_BUFFER(PFILE) ((PFILE)->buffer)
#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
actually processed until we hit cpp_start_read. It consists of
/* This structure is used for the table of all includes. It is
indexed by the `short name' (the name as it appeared in the
#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
different (partial) pathname). */
- struct include_hash *next_this_file;
+ struct ihash *next_this_file;
/* Location of the file in the include search path.
Used for include_next */
char *buf, *limit; /* for file content cache,
not yet implemented */
};
+typedef struct ihash IHASH;
/* Name under which this program was invoked. */
/* Stack of conditionals currently in progress
(including both successful and failing conditionals). */
-struct if_stack {
- struct if_stack *next; /* for chaining to the next stack frame */
- const char *fname; /* copied from input when frame is made */
- int lineno; /* similarly */
- int if_succeeded; /* true if a leg of this if-group
- has been passed through rescan */
- U_CHAR *control_macro; /* For #ifndef at start of file,
- this is the macro name tested. */
+struct if_stack
+{
+ struct if_stack *next;
+ int lineno; /* line number where condition started */
+ int if_succeeded; /* truth of last condition in this group */
+ const U_CHAR *control_macro; /* macro name for #ifndef around entire file */
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 cpp_buffer *cpp_file_buffer PARAMS((cpp_reader *));
extern void _cpp_merge_include_chains PARAMS ((struct cpp_options *));
extern int _cpp_find_include_file PARAMS ((cpp_reader *, const char *,
struct file_name_list *,
- struct include_hash **,
- int *));
-extern int _cpp_read_include_file PARAMS ((cpp_reader *, int,
- struct include_hash *));
+ IHASH **, int *));
+extern int _cpp_read_include_file PARAMS ((cpp_reader *, int, IHASH *));
/* In cppexp.c */
extern HOST_WIDEST_INT _cpp_parse_expr PARAMS ((cpp_reader *));