Wed Oct 27 15:48:58 PDT 1999

(Mandrake)

Now that we've gone through with -ansi -pedantic and there are no more
warnings, maybe Tru64 support will work in epp?


SVN revision: 1002
This commit is contained in:
Mandrake 1999-10-27 15:07:11 +00:00
parent a6fe224828
commit 40bcd3daec
6 changed files with 705 additions and 674 deletions

View File

@ -56,3 +56,11 @@ Wed Oct 27 09:55:14 PDT 1999
(Mandrake)
Trying to get this to build under Tru64
-------------------------------------------------------------------------------
Wed Oct 27 15:48:58 PDT 1999
(Mandrake)
Now that we've gone through with -ansi -pedantic and there are no more
warnings, maybe Tru64 support will work in epp?

View File

@ -317,7 +317,7 @@ cpp_lex(pfile)
case CPP_COMMENT:
goto retry;
case CPP_NUMBER:
return parse_number(pfile, tok_start, tok_end - tok_start);
return parse_number(pfile, (char *)tok_start, tok_end - tok_start);
case CPP_STRING:
cpp_error(pfile, "string constants not allowed in #if expressions");
op.op = ERROR;
@ -1065,7 +1065,7 @@ cpp_parse_expr(pfile)
else
{
new_stack = (struct operation *)xmalloc(new_size);
bcopy((char *)stack, (char *)new_stack, old_size);
memcpy((char *)stack, (char *)new_stack, old_size);
}
stack = new_stack;
top = (struct operation *)((char *)new_stack + old_size);

View File

@ -26,10 +26,10 @@
#include "cpphash.h"
static HASHNODE *hashtab[HASHSIZE];
HASHNODE *cpp_lookup(struct parse_file *pfile, const unsigned char * name, int len,
HASHNODE *cpp_lookup(struct parse_file *pfile, const unsigned char *name, int len,
int hash);
void delete_macro(HASHNODE * hp);
HASHNODE *install(unsigned char * name, int len, enum node_type type, int ivalue,
HASHNODE *install(unsigned char *name, int len, enum node_type type, int ivalue,
char *value, int hash);
/* Define a generic NULL if one hasn't already been defined. */
@ -96,7 +96,7 @@ cpp_lookup(pfile, name, len, hash)
bucket = hashtab[hash];
while (bucket)
{
if (bucket->length == len && strncmp(bucket->name, name, len) == 0)
if (bucket->length == len && strncmp((char *)bucket->name, (char *)name, len) == 0)
return bucket;
bucket = bucket->next;
}
@ -200,7 +200,7 @@ install(name, len, type, ivalue, value, hash)
hp->value.ival = ivalue;
else
hp->value.cpval = value;
hp->name = ((unsigned char *) hp) + sizeof(HASHNODE);
hp->name = ((unsigned char *)hp) + sizeof(HASHNODE);
p = hp->name;
q = name;
for (i = 0; i < len; i++)

View File

@ -1,36 +1,38 @@
enum node_type;
/* different kinds of things that can appear in the value field
of a hash node. Actually, this may be useless now. */
union hashval {
* of a hash node. Actually, this may be useless now. */
union hashval
{
int ival;
char *cpval;
DEFINITION *defn;
};
};
struct hashnode {
struct hashnode
{
struct hashnode *next; /* double links for easy deletion */
struct hashnode *prev;
struct hashnode **bucket_hdr; /* also, a back pointer to this node's hash
chain is kept, in case the node is the head
of the chain and gets deleted. */
* chain is kept, in case the node is the head
* of the chain and gets deleted. */
enum node_type type; /* type of special token */
int length; /* length of token, for quick comparison */
unsigned char *name; /* the actual name */
union hashval value; /* pointer to expansion, or whatever */
};
};
typedef struct hashnode HASHNODE;
/* Some definitions for the hash table. The hash function MUST be
computed as shown in hashf () below. That is because the rescan
loop computes the hash value `on the fly' for most tokens,
in order to avoid the overhead of a lot of procedure calls to
the hashf () function. Hashf () only exists for the sake of
politeness, for use when speed isn't so important. */
* computed as shown in hashf () below. That is because the rescan
* loop computes the hash value `on the fly' for most tokens,
* in order to avoid the overhead of a lot of procedure calls to
* the hashf () function. Hashf () only exists for the sake of
* politeness, for use when speed isn't so important. */
#define HASHSIZE 1403
#define HASHSTEP(old, c) ((old << 2) + c)
#define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */
extern HASHNODE* install PARAMS ((unsigned char*,int,enum node_type, int,char*,int));
extern HASHNODE *install PARAMS((unsigned char *, int, enum node_type, int, char *, int));

View File

@ -87,6 +87,7 @@ char *version_string = "0.0.0";
#if !defined(index) || !defined(_AIX)
extern char *index();
extern char *rindex();
#endif
#ifndef O_RDONLY
@ -264,8 +265,8 @@ extern void delete_macro();
static int finclude(cpp_reader * pfile, int f, char *fname,
int system_header_p, struct file_name_list *dirptr);
static void validate_else(cpp_reader * pfile, char *directive);
static int comp_def_part(int first, unsigned char * beg1, int len1,
unsigned char * beg2, int len2, int last);
static int comp_def_part(int first, unsigned char *beg1, int len1,
unsigned char *beg2, int len2, int last);
extern void fancy_abort();
static int lookup_import(cpp_reader * pfile, char *filename,
struct file_name_list *searchptr);
@ -277,12 +278,12 @@ static struct file_name_map *read_name_map();
static char *read_filename_string();
static int open_include_file(cpp_reader * pfile, char *filename,
struct file_name_list *searchptr);
static int check_macro_name(cpp_reader * pfile, unsigned char * symname,
static int check_macro_name(cpp_reader * pfile, unsigned char *symname,
char *usage);
static int compare_defs();
static int compare_token_lists(struct arglist *l1, struct arglist *l2);
static HOST_WIDE_INT eval_if_expression(cpp_reader * pfile, unsigned char * buf,
static HOST_WIDE_INT eval_if_expression(cpp_reader * pfile, unsigned char *buf,
int length);
static int change_newlines();
@ -293,7 +294,7 @@ static struct arglist *read_token_list(cpp_reader * pfile, int *error_flag);
static void free_token_list(struct arglist *tokens);
static int safe_read(int desc, char *ptr, int len);
static void push_macro_expansion(cpp_reader * pfile,
register unsigned char * x,
register unsigned char *x,
int xbuf_len,
HASHNODE * hp);
@ -301,7 +302,7 @@ static struct cpp_pending *nreverse_pending(struct cpp_pending *list);
static char *savestring(char *input);
static void conditional_skip(cpp_reader * pfile, int skip,
enum node_type type, unsigned char * control_macro);
enum node_type type, unsigned char *control_macro);
static void skip_if_group(cpp_reader * pfile, int any);
/* Last arg to output_line_command. */
@ -323,55 +324,55 @@ extern struct tm *localtime();
* are going to be placed in a table and some old compilers have trouble with
* pointers to functions returning void. */
static int do_define(cpp_reader * pfile, struct directive *keyword, unsigned char * buf,
unsigned char * limit);
static int do_define(cpp_reader * pfile, struct directive *keyword, unsigned char *buf,
unsigned char *limit);
static int do_line(cpp_reader * pfile, struct directive *keyword);
static int do_include(cpp_reader * pfile, struct directive *keyword,
unsigned char * unused1, unsigned char * unused2);
unsigned char *unused1, unsigned char *unused2);
static int do_undef(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
static int do_error(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
static int do_pragma(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
static int do_ident(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
static int do_if(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
static int do_xifdef(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
static int do_else(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
static int do_elif(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
static int do_endif(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
static int do_once(cpp_reader * pfile);
static int do_assert(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
static int do_unassert(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
static int do_warning(cpp_reader * pfile, struct directive *keyword,
unsigned char * buf, unsigned char * limit);
unsigned char *buf, unsigned char *limit);
struct arglist *reverse_token_list(struct arglist *tokens);
void parse_set_mark(struct parse_marker *pmark, cpp_reader * pfile);
int check_assertion(cpp_reader * pfile, unsigned char * name, int sym_length,
int check_assertion(cpp_reader * pfile, unsigned char *name, int sym_length,
int tokens_specified, struct arglist *tokens);
void parse_clear_mark(struct parse_marker *pmark);
void parse_goto_mark(struct parse_marker *pmark, cpp_reader * pfile);
@ -580,7 +581,7 @@ quote_string(pfile, src)
CPP_PUTC_Q(pfile, c);
else
{
sprintf(CPP_PWRITTEN(pfile), "\\%03o", c);
sprintf((char *)CPP_PWRITTEN(pfile), "\\%03o", c);
CPP_ADJUST_WRITTEN(pfile, 4);
}
break;
@ -637,8 +638,8 @@ cpp_define(pfile, str)
while (is_idchar[*++p]);
if (*p == 0)
{
buf = (unsigned char *) alloca(p - buf + 4);
strcpy((char *)buf, str);
buf = (unsigned char *)alloca(p - buf + 4);
strcpy((char *)buf, (char *)str);
strcat((char *)buf, " 1");
}
else if (*p != '=')
@ -651,8 +652,8 @@ cpp_define(pfile, str)
unsigned char *q;
/* Copy the entire option so we can modify it. */
buf = (unsigned char *) alloca(2 * strlen(str) + 1);
strncpy(buf, str, p - str);
buf = (unsigned char *)alloca(2 * strlen((char *)str) + 1);
strncpy((char *)buf, (char *)str, p - str);
/* Change the = to a space. */
buf[p - str] = ' ';
/* Scan for any backslash-newline and remove it. */
@ -668,7 +669,7 @@ cpp_define(pfile, str)
*q = 0;
}
do_define(pfile, NULL, buf, buf + strlen(buf));
do_define(pfile, NULL, buf, buf + strlen((char *)buf));
}
/* Process the string STR as if it appeared as the body of a #assert.
@ -684,8 +685,8 @@ make_assertion(pfile, option, str)
unsigned char *buf, *p, *q;
/* Copy the entire option so we can modify it. */
buf = (unsigned char *) alloca(strlen(str) + 1);
strcpy((char *)buf, str);
buf = (unsigned char *)alloca(strlen((char *)str) + 1);
strcpy((char *)buf, (char *)str);
/* Scan for any backslash-newline and remove it. */
p = q = buf;
while (*p)
@ -708,7 +709,7 @@ make_assertion(pfile, option, str)
cpp_error(pfile, "malformed option `%s %s'", option, str);
return;
}
ip = cpp_push_buffer(pfile, buf, strlen(buf));
ip = cpp_push_buffer(pfile, buf, strlen((char *)buf));
do_assert(pfile, NULL, NULL, NULL);
cpp_pop_buffer(pfile);
}
@ -784,7 +785,7 @@ deps_output(pfile, string, spacer)
}
if (spacer == ' ' && pfile->deps_column > 0)
pfile->deps_buffer[pfile->deps_size++] = ' ';
bcopy(string, &pfile->deps_buffer[pfile->deps_size], size);
memcpy(string, &pfile->deps_buffer[pfile->deps_size], size);
pfile->deps_size += size;
pfile->deps_column += size;
if (spacer == ':')
@ -825,7 +826,7 @@ path_include(pfile, path)
{
/* Otherwise use the directory that is named. */
name = (char *)xmalloc(q - p + 1);
bcopy(p, name, q - p);
memcpy(p, name, q - p);
name[q - p] = 0;
}
@ -852,7 +853,7 @@ void
init_parse_options(opts)
struct cpp_options *opts;
{
bzero((char *)opts, sizeof *opts);
memset((char *)opts, 0, sizeof *opts);
opts->in_fname = NULL;
opts->out_fname = NULL;
@ -1143,7 +1144,7 @@ handle_directive(pfile)
{
if (kt->length <= 0)
goto not_a_directive;
if (kt->length == ident_length && !strncmp(kt->name, ident, ident_length))
if (kt->length == ident_length && !strncmp(kt->name, (char *)ident, ident_length))
break;
}
@ -1298,7 +1299,7 @@ collect_expansion(pfile, buf, limit, nargs, arglist)
defn = (DEFINITION *) xcalloc(1, maxsize);
defn->nargs = nargs;
exp_p = defn->expansion = (unsigned char *) defn + sizeof(DEFINITION);
exp_p = defn->expansion = (unsigned char *)defn + sizeof(DEFINITION);
lastp = exp_p;
p = buf;
@ -1453,7 +1454,7 @@ collect_expansion(pfile, buf, limit, nargs, arglist)
if (arg->name[0] == c
&& arg->length == id_len
&& strncmp(arg->name, id_beg, id_len) == 0)
&& strncmp((char *)arg->name, (char *)id_beg, id_len) == 0)
{
if (expected_delimiter && CPP_OPTIONS(pfile)->warn_stringify)
{
@ -1583,7 +1584,8 @@ create_definition(buf, limit, pfile, predefinition)
* * * * * * * * *
* * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * * * plus number of args. */
* * * * * * * * * * * *
* * * * * * * * * * * * * plus number of args. */
MACRODEF mdef;
cpp_buf_line_and_col(CPP_BUFFER(pfile), &line, &col);
@ -1635,7 +1637,7 @@ create_definition(buf, limit, pfile, predefinition)
bp++;
/* do we have a "special" rest-args extension here? */
if ((unsigned)(limit - bp) > REST_EXTENSION_LENGTH &&
strncmp(rest_extension, bp, REST_EXTENSION_LENGTH) == 0)
strncmp(rest_extension, (char *)bp, REST_EXTENSION_LENGTH) == 0)
{
rest_args = 1;
temp->rest_args = 1;
@ -1667,12 +1669,12 @@ create_definition(buf, limit, pfile, predefinition)
for (otemp = temp->next; otemp != NULL; otemp = otemp->next)
if (temp->length == otemp->length &&
strncmp(temp->name, otemp->name, temp->length) == 0)
strncmp((char *)temp->name, (char *)otemp->name, temp->length) == 0)
{
unsigned char *name;
name = (unsigned char *) alloca(temp->length + 1);
(void)strncpy(name, temp->name, temp->length);
name = (unsigned char *)alloca(temp->length + 1);
(void)strncpy((char *)name, (char *)temp->name, temp->length);
name[temp->length] = '\0';
cpp_error(pfile,
"duplicate argument name `%s' in `#define'", name);
@ -1690,14 +1692,14 @@ create_definition(buf, limit, pfile, predefinition)
/* Now set defn->args.argnames to the result of concatenating
* the argument names in reverse order
* with comma-space between them. */
defn->args.argnames = (unsigned char *) xmalloc(arglengths + 1);
defn->args.argnames = (unsigned char *)xmalloc(arglengths + 1);
{
struct arglist *temp;
int i = 0;
for (temp = arg_ptrs; temp; temp = temp->next)
{
bcopy(temp->name, &defn->args.argnames[i], temp->length);
memcpy(temp->name, &defn->args.argnames[i], temp->length);
i += temp->length;
if (temp->next != 0)
{
@ -1763,7 +1765,7 @@ create_definition(buf, limit, pfile, predefinition)
}
/* now everything from bp before limit is the definition. */
defn = collect_expansion(pfile, bp, limit, -1, NULL_PTR);
defn->args.argnames = (unsigned char *) "";
defn->args.argnames = (unsigned char *)"";
}
defn->line = line;
@ -1804,14 +1806,14 @@ check_macro_name(pfile, symname, usage)
{
unsigned char *msg; /* what pain... */
msg = (unsigned char *) alloca(sym_length + 1);
bcopy(symname, msg, sym_length);
msg = (unsigned char *)alloca(sym_length + 1);
memcpy(symname, msg, sym_length);
msg[sym_length] = 0;
cpp_error(pfile, "invalid %s name `%s'", usage, msg);
}
else
{
if (!strncmp(symname, "defined", 7) && sym_length == 7)
if (!strncmp((char *)symname, "defined", 7) && sym_length == 7)
cpp_error(pfile, "invalid %s name `defined'", usage);
}
return sym_length;
@ -1836,7 +1838,7 @@ compare_defs(d1, d2)
for (a1 = d1->pattern, a2 = d2->pattern; a1 && a2;
a1 = a1->next, a2 = a2->next)
{
if (!((a1->nchars == a2->nchars && !strncmp(p1, p2, a1->nchars))
if (!((a1->nchars == a2->nchars && !strncmp((char *)p1, (char *)p2, a1->nchars))
|| !comp_def_part(first, p1, a1->nchars, p2, a2->nchars, 0))
|| a1->argno != a2->argno
|| a1->stringify != a2->stringify
@ -1953,9 +1955,9 @@ do_define(pfile, keyword, buf, limit)
if (CPP_OPTIONS(pfile)->debug_output && keyword)
pass_thru_directive(buf, limit, pfile, keyword);
msg = (unsigned char *) alloca(mdef.symlen + 22);
msg = (unsigned char *)alloca(mdef.symlen + 22);
*msg = '`';
bcopy(mdef.symnam, msg + 1, mdef.symlen);
memcpy(mdef.symnam, msg + 1, mdef.symlen);
strcpy((char *)(msg + mdef.symlen + 1), "' redefined");
cpp_pedwarn(pfile, msg);
if (hp->type == T_MACRO)
@ -2018,12 +2020,12 @@ cpp_push_buffer(pfile, buffer, length)
if (buf == pfile->buffer_stack)
fatal("macro or `#include' recursion too deep");
buf--;
bzero((char *)buf, sizeof(cpp_buffer));
memset((char *)buf, 0, sizeof(cpp_buffer));
CPP_BUFFER(pfile) = buf;
#else
register cpp_buffer *buf = (cpp_buffer *) xmalloc(sizeof(cpp_buffer));
bzero((char *)buf, sizeof(cpp_buffer));
memset((char *)buf, 0, sizeof(cpp_buffer));
CPP_PREV_BUFFER(buf) = CPP_BUFFER(pfile);
CPP_BUFFER(pfile) = buf;
#endif
@ -2102,7 +2104,7 @@ cpp_expand_to_buffer(pfile, buf, length)
/* Set up the input on the input stack. */
buf1 = (unsigned char *) alloca(length + 1);
buf1 = (unsigned char *)alloca(length + 1);
{
register unsigned char *p1 = buf;
register unsigned char *p2 = buf1;
@ -2269,8 +2271,8 @@ output_line_command(pfile, conditional, file_change)
CPP_PUTS_Q(pfile, sharp_line, sizeof(sharp_line) - 1);
}
sprintf(CPP_PWRITTEN(pfile), "%d ", (int)line);
CPP_ADJUST_WRITTEN(pfile, strlen(CPP_PWRITTEN(pfile)));
sprintf((char *)CPP_PWRITTEN(pfile), "%d ", (int)line);
CPP_ADJUST_WRITTEN(pfile, strlen((char *)CPP_PWRITTEN(pfile)));
quote_string(pfile, ip->nominal_fname);
if (file_change != same_file)
@ -2926,7 +2928,8 @@ macroexpand(pfile, hp)
* * * * * * * * *
* * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * * * copied a piece at a time */
* * * * * * * * * * * *
* * * * * * * * * * * * * copied a piece at a time */
register int totlen; /* total amount of exp buffer filled so far */
register struct reflist *ap, *last_ap;
@ -3007,7 +3010,7 @@ macroexpand(pfile, hp)
else
{
CPP_RESERVE(pfile, 4);
sprintf(CPP_PWRITTEN(pfile), "\\%03o",
sprintf((char *)CPP_PWRITTEN(pfile), "\\%03o",
(unsigned int)c);
CPP_ADJUST_WRITTEN(pfile, 4);
}
@ -3045,7 +3048,7 @@ macroexpand(pfile, hp)
args[ap->argno].use_count++;
}
xbuf = (unsigned char *) xmalloc(xbuf_len + 1);
xbuf = (unsigned char *)xmalloc(xbuf_len + 1);
/* Generate in XBUF the complete expansion
* with arguments substituted in.
@ -3080,7 +3083,7 @@ macroexpand(pfile, hp)
}
if (ap->stringify != 0)
{
bcopy(ARG_BASE + arg->stringified,
memcpy(ARG_BASE + arg->stringified,
xbuf + totlen, arg->stringified_length);
totlen += arg->stringified_length;
}
@ -3123,7 +3126,7 @@ macroexpand(pfile, hp)
break;
}
}
bcopy(p1, xbuf + totlen, l1 - p1);
memcpy(p1, xbuf + totlen, l1 - p1);
totlen += l1 - p1;
}
else
@ -3137,7 +3140,7 @@ macroexpand(pfile, hp)
xbuf[totlen++] = '@';
xbuf[totlen++] = ' ';
}
bcopy(expanded, xbuf + totlen, arg->expand_length);
memcpy(expanded, xbuf + totlen, arg->expand_length);
totlen += arg->expand_length;
if (!ap->raw_after && totlen > 0 && offset < defn->length
@ -3449,7 +3452,7 @@ do_include(pfile, keyword, unused1, unused2)
if (_fnisabs(fbeg))
#endif
{
strncpy(fname, fbeg, flen);
strncpy(fname, (char *)fbeg, flen);
fname[flen] = 0;
if (redundant_include_p(pfile, fname))
return 0;
@ -3482,7 +3485,7 @@ do_include(pfile, keyword, unused1, unused2)
{
fname[0] = 0;
}
strncat(fname, fbeg, flen);
strncat(fname, (char *)fbeg, flen);
#ifdef VMS
/* Change this 1/2 Unix 1/2 VMS file specification into a
* full VMS file specification */
@ -3527,7 +3530,7 @@ do_include(pfile, keyword, unused1, unused2)
if (f < 0)
{
/* A file that was not found. */
strncpy(fname, fbeg, flen);
strncpy(fname, (char *)fbeg, flen);
fname[flen] = 0;
/* If generating dependencies and -MG was specified, we assume missing
* files are leaf files, living in the same directory as the source file
@ -3744,7 +3747,7 @@ assertion_install(pfile, name, len, hash)
hp->next->prev = hp;
hp->length = len;
hp->value = 0;
hp->name = ((unsigned char *) hp) + sizeof(ASSERTION_HASHNODE);
hp->name = ((unsigned char *)hp) + sizeof(ASSERTION_HASHNODE);
p = hp->name;
q = name;
for (i = 0; i < len; i++)
@ -3775,7 +3778,7 @@ assertion_lookup(pfile, name, len, hash)
bucket = pfile->assertion_hashtab[hash];
while (bucket)
{
if (bucket->length == len && strncmp(bucket->name, name, len) == 0)
if (bucket->length == len && strncmp((char *)bucket->name, (char *)name, len) == 0)
return bucket;
bucket = bucket->next;
}
@ -3842,11 +3845,11 @@ convert_string(pfile, result, in, limit, handle_escapes)
if (handle_escapes)
{
char *bpc = (char *)in;
int i = (unsigned char) cpp_parse_escape(pfile, &bpc);
int i = (unsigned char)cpp_parse_escape(pfile, &bpc);
in = (unsigned char *) bpc;
in = (unsigned char *)bpc;
if (i >= 0)
*result++ = (unsigned char) c;
*result++ = (unsigned char)c;
break;
}
/* else fall through */
@ -3887,7 +3890,7 @@ do_line(pfile, keyword)
/* The Newline at the end of this line remains to be processed.
* To put the next line at the specified line number,
* we must store a line number now that is one less. */
new_lineno = atoi(pfile->token_buffer + old_written) - 1;
new_lineno = atoi((char *)(pfile->token_buffer + old_written)) - 1;
CPP_SET_WRITTEN(pfile, old_written);
/* NEW_LINENO is one less than the actual line number here. */
@ -3956,7 +3959,7 @@ do_line(pfile, keyword)
&fname_table[hashf(fname, fname_length, FNAME_HASHSIZE)];
for (hp = *hash_bucket; hp != NULL; hp = hp->next)
if (hp->length == fname_length &&
strncmp(hp->value.cpval, fname, fname_length) == 0)
strncmp(hp->value.cpval, (char *)fname, fname_length) == 0)
{
ip->nominal_fname = hp->value.cpval;
break;
@ -3970,7 +3973,7 @@ do_line(pfile, keyword)
hp->length = fname_length;
ip->nominal_fname = hp->value.cpval = ((char *)hp) + sizeof(HASHNODE);
bcopy(fname, hp->value.cpval, fname_length);
memcpy(fname, hp->value.cpval, fname_length);
}
}
else if (token != CPP_VSPACE && token != CPP_EOF)
@ -4039,10 +4042,10 @@ do_error(pfile, keyword, buf, limit)
unsigned char *buf, *limit;
{
int length = limit - buf;
unsigned char *copy = (unsigned char *) xmalloc(length + 1);
unsigned char *copy = (unsigned char *)xmalloc(length + 1);
keyword = NULL;
bcopy(buf, copy, length);
memcpy(buf, copy, length);
copy[length] = 0;
SKIP_WHITE_SPACE(copy);
cpp_error(pfile, "#error %s", copy);
@ -4062,10 +4065,10 @@ do_warning(pfile, keyword, buf, limit)
unsigned char *buf, *limit;
{
int length = limit - buf;
unsigned char *copy = (unsigned char *) xmalloc(length + 1);
unsigned char *copy = (unsigned char *)xmalloc(length + 1);
keyword = NULL;
bcopy(buf, copy, length);
memcpy(buf, copy, length);
copy[length] = 0;
SKIP_WHITE_SPACE(copy);
cpp_warning(pfile, "#warning %s", copy);
@ -4138,7 +4141,7 @@ do_pragma(pfile, keyword, buf, limit)
keyword = NULL;
limit = NULL;
if (!strncmp(buf, "once", 4))
if (!strncmp((char *)buf, "once", 4))
{
/* Allow #pragma once in system headers, since that's not the user's
* fault. */
@ -4146,7 +4149,7 @@ do_pragma(pfile, keyword, buf, limit)
cpp_warning(pfile, "`#pragma once' is obsolete");
do_once(pfile);
}
if (!strncmp(buf, "implementation", 14))
if (!strncmp((char *)buf, "implementation", 14))
{
/* Be quiet about `#pragma implementation' for a file only if it hasn't
* been included yet. */
@ -4159,14 +4162,14 @@ do_pragma(pfile, keyword, buf, limit)
return 0;
fname = p + 1;
p = (unsigned char *) index(fname, '\"');
fname_len = p != NULL ? p - fname : strlen(fname);
p = (unsigned char *)index(fname, '\"');
fname_len = p != NULL ? p - fname : strlen((char *)fname);
for (ptr = pfile->all_include_files; ptr; ptr = ptr->next)
{
inc_fname = (unsigned char *) rindex(ptr->fname, '/');
inc_fname = inc_fname ? inc_fname + 1 : (unsigned char *) ptr->fname;
if (inc_fname && !strncmp(inc_fname, fname, fname_len))
inc_fname = (unsigned char *)rindex(ptr->fname, '/');
inc_fname = inc_fname ? inc_fname + 1 : (unsigned char *)ptr->fname;
if (inc_fname && !strncmp((char *)inc_fname, (char *)fname, fname_len))
cpp_warning(pfile,
"`#pragma implementation' for `%s' appears after file is included",
fname);
@ -4329,8 +4332,8 @@ do_xifdef(pfile, keyword, unused1, unused2)
skip = (hp == NULL) ^ (keyword->type == T_IFNDEF);
if (start_of_file && !skip)
{
control_macro = (unsigned char *) xmalloc(ident_length + 1);
bcopy(ident, control_macro, ident_length + 1);
control_macro = (unsigned char *)xmalloc(ident_length + 1);
memcpy(ident, control_macro, ident_length + 1);
}
}
else
@ -4448,7 +4451,7 @@ skip_if_group(pfile, any)
IF_STACK_FRAME *temp;
if (ident_length == kt->length
&& strncmp(ident, kt->name, kt->length) == 0)
&& strncmp((char *)ident, kt->name, kt->length) == 0)
{
/* If we are asked to return on next directive, do so now. */
if (any)
@ -5274,9 +5277,9 @@ cpp_get_token(pfile)
CPP_SET_WRITTEN(pfile, before_name_written);
special_symbol(hp, pfile);
xbuf_len = CPP_WRITTEN(pfile) - before_name_written;
xbuf = (unsigned char *) xmalloc(xbuf_len + 1);
xbuf = (unsigned char *)xmalloc(xbuf_len + 1);
CPP_SET_WRITTEN(pfile, before_name_written);
bcopy(CPP_PWRITTEN(pfile), xbuf, xbuf_len + 1);
memcpy(CPP_PWRITTEN(pfile), xbuf, xbuf_len + 1);
push_macro_expansion(pfile, xbuf, xbuf_len, hp);
}
else
@ -5469,7 +5472,7 @@ lookup_import(pfile, filename, searchptr)
{
/* Compare the inode and the device.
* Supposedly on some systems the inode is not a scalar. */
if (!bcmp((char *)&i->inode, (char *)&sb.st_ino, sizeof(sb.st_ino))
if (!memcmp((char *)&i->inode, (char *)&sb.st_ino, sizeof(sb.st_ino))
&& i->dev == sb.st_dev)
{
close(fd);
@ -5500,7 +5503,7 @@ add_import(pfile, fd, fname)
i->name = (char *)xmalloc(strlen(fname) + 1);
strcpy(i->name, fname);
bcopy((char *)&sb.st_ino, (char *)&i->inode, sizeof(sb.st_ino));
memcpy((char *)&sb.st_ino, (char *)&i->inode, sizeof(sb.st_ino));
i->dev = sb.st_dev;
i->next = pfile->import_hash_table[hashval];
pfile->import_hash_table[hashval] = i;
@ -5709,7 +5712,7 @@ open_include_file(pfile, filename, searchptr)
else
{
dir = (char *)alloca(p - filename + 1);
bcopy(filename, dir, p - filename);
memcpy(filename, dir, p - filename);
dir[p - filename] = '\0';
from = p + 1;
}
@ -5763,13 +5766,13 @@ finclude(pfile, f, fname, system_header_p, dirptr)
if (S_ISREG(st_mode))
{
fp->buf = (unsigned char *) xmalloc(st_size + 2);
fp->buf = (unsigned char *)xmalloc(st_size + 2);
fp->alimit = fp->buf + st_size + 2;
fp->cur = fp->buf;
/* Read the file contents, knowing that st_size is an upper bound
* on the number of bytes we can read. */
length = safe_read(f, fp->buf, st_size);
length = safe_read(f, (char *)fp->buf, st_size);
fp->rlimit = fp->buf + length;
if (length < 0)
goto nope;
@ -5789,18 +5792,18 @@ finclude(pfile, f, fname, system_header_p, dirptr)
int bsize = 2000;
st_size = 0;
fp->buf = (unsigned char *) xmalloc(bsize + 2);
fp->buf = (unsigned char *)xmalloc(bsize + 2);
for (;;)
{
i = safe_read(f, fp->buf + st_size, bsize - st_size);
i = safe_read(f, (char *)fp->buf + st_size, bsize - st_size);
if (i < 0)
goto nope; /* error! */
st_size += i;
if (st_size != bsize)
break; /* End of file */
bsize *= 2;
fp->buf = (unsigned char *) xrealloc(fp->buf, bsize + 2);
fp->buf = (unsigned char *)xrealloc(fp->buf, bsize + 2);
}
length = st_size;
}
@ -5898,7 +5901,7 @@ push_parse_file(pfile, fname)
*p++ = 0;
if (opts->debug_output)
output_line_command(pfile, 0, same_file);
cpp_define(pfile, q);
cpp_define(pfile, (unsigned char *)q);
while (*p == ' ' || *p == '\t')
p++;
}
@ -5969,12 +5972,13 @@ push_parse_file(pfile, fname)
case 'U':
if (opts->debug_output)
output_line_command(pfile, 0, same_file);
do_undef(pfile, NULL, pend->arg, pend->arg + strlen(pend->arg));
do_undef(pfile, NULL, (unsigned char *)pend->arg,
(unsigned char *)pend->arg + strlen(pend->arg));
break;
case 'D':
if (opts->debug_output)
output_line_command(pfile, 0, same_file);
cpp_define(pfile, pend->arg);
cpp_define(pfile, (unsigned char *)pend->arg);
break;
case 'A':
make_assertion(pfile, "-A", pend->arg);
@ -6046,7 +6050,7 @@ push_parse_file(pfile, fname)
endp++;
}
/* Put the usual defaults back in at the end. */
bcopy((char *)include_defaults_array,
memcpy((char *)include_defaults_array,
(char *)&include_defaults[num_dirs],
sizeof(include_defaults_array));
}
@ -6211,7 +6215,7 @@ push_parse_file(pfile, fname)
{
opts->deps_target = s + 1;
output_file = (char *)xmalloc(s - spec + 1);
bcopy(spec, output_file, s - spec);
memcpy(spec, output_file, s - spec);
output_file[s - spec] = 0;
}
else
@ -6331,11 +6335,11 @@ init_parse_file(pfile)
cpp_reader *pfile;
{
bzero((char *)pfile, sizeof(cpp_reader));
memset((char *)pfile, 0, sizeof(cpp_reader));
pfile->get_token = cpp_get_token;
pfile->token_buffer_size = 200;
pfile->token_buffer = (unsigned char *) xmalloc(pfile->token_buffer_size);
pfile->token_buffer = (unsigned char *)xmalloc(pfile->token_buffer_size);
CPP_SET_WRITTEN(pfile, 0);
pfile->system_include_depth = 0;
@ -6964,7 +6968,7 @@ do_assert(pfile, keyword, buf, limit)
hp = assertion_lookup(pfile, symname, sym_length, hashcode);
if (hp == NULL)
{
if (sym_length == 7 && !strncmp(symname, "defined", sym_length))
if (sym_length == 7 && !strncmp((char *)symname, "defined", sym_length))
cpp_error(pfile, "`defined' redefined as assertion");
hp = assertion_install(pfile, symname, sym_length, hashcode);
}
@ -7141,7 +7145,7 @@ compare_token_lists(l1, l2)
{
if (l1->length != l2->length)
return 0;
if (strncmp(l1->name, l2->name, l1->length))
if (strncmp((char *)l1->name, (char *)l2->name, l1->length))
return 0;
l1 = l1->next;
l2 = l2->next;
@ -7231,8 +7235,8 @@ read_token_list(pfile, error_flag)
temp = (struct arglist *)
xmalloc(sizeof(struct arglist) + length + 1);
temp->name = (unsigned char *) (temp + 1);
bcopy((char *)(pfile->token_buffer + name_written),
temp->name = (unsigned char *)(temp + 1);
memcpy((char *)(pfile->token_buffer + name_written),
(char *)temp->name, length);
temp->name[length] = 0;
temp->next = token_ptrs;

View File

@ -1,41 +1,44 @@
/* Definitions for CPP library.
Copyright (C) 1995 Free Software Foundation, Inc.
Written by Per Bothner, 1994-95.
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
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
* Copyright (C) 1995 Free Software Foundation, Inc.
* Written by Per Bothner, 1994-95.
*
* 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
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* In other words, you are welcome to use, share and improve this program.
* You are forbidden to forbid anyone else to use, share and improve
* what you give them. Help stamp out software-hoarding! */
#include <sys/types.h>
#include <sys/stat.h>
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#define STATIC_BUFFERS
struct parse_file;
typedef struct cpp_reader cpp_reader;
typedef struct cpp_buffer cpp_buffer;
typedef struct cpp_options cpp_options;
typedef struct hashnode cpp_hashnode;
struct parse_file;
typedef struct cpp_reader cpp_reader;
typedef struct cpp_buffer cpp_buffer;
typedef struct cpp_options cpp_options;
typedef struct hashnode cpp_hashnode;
enum cpp_token {
enum cpp_token
{
CPP_EOF = -1,
CPP_OTHER = 0,
CPP_COMMENT = 1,
@ -51,11 +54,11 @@ enum cpp_token {
CPP_LBRACE, /* "{" */
CPP_RBRACE, /* "}" */
CPP_COMMA, /* "," */
CPP_SEMICOLON,/* ";" */
CPP_SEMICOLON, /* ";" */
CPP_3DOTS, /* "..." */
/* POP_TOKEN is returned when we've popped a cpp_buffer. */
CPP_POP
};
};
#ifndef PARAMS
#ifdef __STDC
@ -65,44 +68,46 @@ enum cpp_token {
#endif
#endif /* !PARAMS */
typedef enum cpp_token (*parse_underflow_t) PARAMS((cpp_reader*));
typedef int (*parse_cleanup_t) PARAMS((cpp_buffer *, cpp_reader*));
typedef enum cpp_token (*parse_underflow_t) PARAMS((cpp_reader *));
typedef int (*parse_cleanup_t) PARAMS((cpp_buffer *, cpp_reader *));
/* A parse_marker indicates a previous position,
which we can backtrack to. */
* which we can backtrack to. */
struct parse_marker {
struct parse_marker
{
cpp_buffer *buf;
struct parse_marker *next;
int position;
};
};
extern void parse_set_mark PARAMS ((struct parse_marker*, cpp_reader*));
extern void parse_clear_mark PARAMS ((struct parse_marker*));
extern void parse_goto_mark PARAMS((struct parse_marker*, cpp_reader*));
extern void parse_move_mark PARAMS((struct parse_marker*, cpp_reader*));
extern int cpp_handle_options PARAMS ((cpp_reader*, int, char**));
extern enum cpp_token cpp_get_token PARAMS ((struct parse_marker*));
extern void cpp_skip_hspace PARAMS((cpp_reader*));
extern enum cpp_token cpp_get_non_space_token PARAMS ((cpp_reader *));
extern void parse_set_mark PARAMS((struct parse_marker *, cpp_reader *));
extern void parse_clear_mark PARAMS((struct parse_marker *));
extern void parse_goto_mark PARAMS((struct parse_marker *, cpp_reader *));
extern void parse_move_mark PARAMS((struct parse_marker *, cpp_reader *));
extern int cpp_handle_options PARAMS((cpp_reader *, int, char **));
extern enum cpp_token cpp_get_token PARAMS((struct parse_marker *));
extern void cpp_skip_hspace PARAMS((cpp_reader *));
extern enum cpp_token cpp_get_non_space_token PARAMS((cpp_reader *));
/* Maintain and search list of included files, for #import. */
#define IMPORT_HASH_SIZE 31
struct import_file {
struct import_file
{
char *name;
ino_t inode;
dev_t dev;
struct import_file *next;
};
};
/* If we have a huge buffer, may need to cache more recent counts */
#define CPP_LINE_BASE(BUF) ((BUF)->buf + (BUF)->line_base)
struct cpp_buffer {
struct cpp_buffer
{
unsigned char *buf;
unsigned char *cur;
unsigned char *rlimit; /* end of valid data */
@ -114,7 +119,7 @@ struct cpp_buffer {
char *nominal_fname;
/* Record where in the search path this file was found.
For #include_next. */
* For #include_next. */
struct file_name_list *dir;
long line_base;
@ -128,7 +133,7 @@ struct cpp_buffer {
void *data;
struct parse_marker *marks;
/* Value of if_stack at start of this file.
Used to prohibit unmatched #endif (etc) in an include file. */
* Used to prohibit unmatched #endif (etc) in an include file. */
struct if_stack *if_stack;
/* True if this is a header file included using <FILENAME>. */
@ -136,28 +141,29 @@ struct cpp_buffer {
char seen_eof;
/* True if buffer contains escape sequences.
Currently there are are only two kind:
"@-" means following identifier should not be macro-expanded.
"@ " means a token-separator. This turns into " " in final output
if not stringizing and needed to separate tokens; otherwise nothing.
"@@" means a normal '@'.
(An '@' inside a string stands for itself and is never an escape.) */
* Currently there are are only two kind:
* "@-" means following identifier should not be macro-expanded.
* "@ " means a token-separator. This turns into " " in final output
* if not stringizing and needed to separate tokens; otherwise nothing.
* "@@" means a normal '@'.
* (An '@' inside a string stands for itself and is never an escape.) */
char has_escapes;
};
};
struct cpp_pending; /* Forward declaration - for C++. */
struct file_name_map_list;
struct cpp_pending; /* Forward declaration - for C++. */
struct file_name_map_list;
typedef struct assertion_hashnode ASSERTION_HASHNODE;
typedef struct assertion_hashnode ASSERTION_HASHNODE;
#define ASSERTION_HASHSIZE 37
#ifdef STATIC_BUFFERS
/* Maximum nesting of cpp_buffers. We use a static limit, partly for
efficiency, and partly to limit runaway recursion. */
* efficiency, and partly to limit runaway recursion. */
#define CPP_STACK_MAX 200
#endif
struct cpp_reader {
struct cpp_reader
{
unsigned char *limit;
parse_underflow_t get_token;
cpp_buffer *buffer;
@ -181,12 +187,12 @@ struct cpp_reader {
struct file_name_list *dont_repeat_files;
/* List of other included files.
If ->control_macro if nonzero, the file had a #ifndef
around the entire contents, and ->control_macro gives the macro name. */
* If ->control_macro if nonzero, the file had a #ifndef
* around the entire contents, and ->control_macro gives the macro name. */
struct file_name_list *all_include_files;
/* Current maximum length of directory names in the search path
for include files. (Altered as we get more of them.) */
* for include files. (Altered as we get more of them.) */
int max_include_len;
/* Hash table of files already included with #include or #import. */
@ -195,12 +201,12 @@ struct cpp_reader {
struct if_stack *if_stack;
/* Nonzero means we are inside an IF during a -pcp run. In this mode
macro expansion is done, and preconditions are output for all macro
uses requiring them. */
* macro expansion is done, and preconditions are output for all macro
* uses requiring them. */
char pcp_inside_if;
/* Nonzero means we have printed (while error reporting) a list of
containing files that matches the current status. */
* containing files that matches the current status. */
char input_stack_listing_current;
/* If non-zero, macros are not expanded. */
@ -216,16 +222,16 @@ struct cpp_reader {
char parsing_include_directive;
/* True if escape sequences (as described for has_escapes in
parse_buffer) should be emitted. */
* parse_buffer) should be emitted. */
char output_escapes;
/* 0: Have seen non-white-space on this line.
1: Only seen white space so far on this line.
2: Only seen white space so far in this file. */
* 1: Only seen white space so far on this line.
* 2: Only seen white space so far in this file. */
char only_seen_white;
/* Nonzero means this file was included with a -imacros or -include
command line and should not be recorded as an include file. */
* command line and should not be recorded as an include file. */
int no_record_file;
@ -246,7 +252,7 @@ struct cpp_reader {
/* Number of bytes since the last newline. */
int deps_column;
};
};
#define CPP_BUF_PEEK(BUFFER) \
((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur : EOF)
@ -264,9 +270,9 @@ struct cpp_reader {
&& (cpp_grow_buffer (PFILE, N), 0))
/* Append string STR (of length N) to PFILE's output buffer.
Assume there is enough space. */
* Assume there is enough space. */
#define CPP_PUTS_Q(PFILE, STR, N) \
(bcopy (STR, (PFILE)->limit, (N)), (PFILE)->limit += (N))
(memcpy (STR, (PFILE)->limit, (N)), (PFILE)->limit += (N))
/* Append string STR (of length N) to PFILE's output buffer. Make space. */
#define CPP_PUTS(PFILE, STR, N) CPP_RESERVE(PFILE, N), CPP_PUTS_Q(PFILE, STR,N)
/* Append character CH to PFILE's output buffer. Assume sufficient space. */
@ -290,7 +296,8 @@ struct cpp_reader {
#endif
/* Pointed to by parse_file::data. */
struct cpp_options {
struct cpp_options
{
char *in_fname;
/* Name of output file, for error messages. */
@ -314,7 +321,7 @@ struct cpp_options {
char objc;
/* Nonzero means this is an assembly file, and allow
unknown directives, which could be comments. */
* unknown directives, which could be comments. */
int lang_asm;
@ -323,7 +330,7 @@ struct cpp_options {
char for_lint;
/* Nonzero means handle CHILL comment syntax
and output CHILL string delimiter for __DATE___ etc. */
* and output CHILL string delimiter for __DATE___ etc. */
char chill;
@ -336,13 +343,13 @@ struct cpp_options {
char no_trigraphs;
/* Nonzero means print the names of included files rather than
the preprocessed output. 1 means just the #include "...",
2 means #include <...> as well. */
* the preprocessed output. 1 means just the #include "...",
* 2 means #include <...> as well. */
char print_deps;
/* Nonzero if missing .h files in -M output are assumed to be generated
files and not errors. */
* files and not errors. */
char print_deps_missing_files;
@ -374,7 +381,7 @@ struct cpp_options {
char warn_import;
/* Nonzero means warn if a macro argument is (or would be)
stringified with -traditional. */
* stringified with -traditional. */
char warn_stringify;
@ -383,8 +390,8 @@ struct cpp_options {
char warnings_are_errors;
/* Nonzero causes output not to be done,
but directives such as #define that have side effects
are still obeyed. */
* but directives such as #define that have side effects
* are still obeyed. */
char no_output;
@ -393,21 +400,21 @@ struct cpp_options {
char no_line_commands;
/* Nonzero means output the text in failing conditionals,
inside #failed ... #endfailed. */
* inside #failed ... #endfailed. */
char output_conditionals;
/* Nonzero means -I- has been seen,
so don't look for #include "foo" the source-file directory. */
* so don't look for #include "foo" the source-file directory. */
char ignore_srcdir;
/* Zero means dollar signs are punctuation.
-$ stores 0; -traditional may store 1. Default is 1 for VMS, 0 otherwise.
This must be 0 for correct processing of this ANSI C program:
#define foo(a) #a
#define lose(b) foo (b)
#define test$
lose (test) */
* -$ stores 0; -traditional may store 1. Default is 1 for VMS, 0 otherwise.
* This must be 0 for correct processing of this ANSI C program:
* #define foo(a) #a
* #define lose(b) foo (b)
* #define test$
* lose (test) */
char dollars_in_ident;
#ifndef DOLLARS_IN_IDENTIFIERS
#define DOLLARS_IN_IDENTIFIERS 1
@ -424,10 +431,10 @@ struct cpp_options {
struct file_name_list *include; /* First dir to search */
/* First dir to search for <file> */
/* This is the first element to use for #include <...>.
If it is 0, use the entire chain for such includes. */
* If it is 0, use the entire chain for such includes. */
struct file_name_list *first_bracket_include;
/* This is the first element in the chain that corresponds to
a directory of system header files. */
* a directory of system header files. */
struct file_name_list *first_system_include;
struct file_name_list *last_include; /* Last in chain */
@ -440,7 +447,7 @@ struct cpp_options {
struct file_name_list *last_before_system; /* Last in chain */
/* Directory prefix that should replace `/usr' in the standard
include file directories. */
* include file directories. */
char *include_prefix;
char inhibit_predefs;
@ -448,33 +455,36 @@ struct cpp_options {
char no_standard_cplusplus_includes;
/* dump_only means inhibit output of the preprocessed text
and instead output the definitions of all user-defined
macros in a form suitable for use as input to cccp.
dump_names means pass #define and the macro name through to output.
dump_definitions means pass the whole definition (plus #define) through
*/
* and instead output the definitions of all user-defined
* macros in a form suitable for use as input to cccp.
* dump_names means pass #define and the macro name through to output.
* dump_definitions means pass the whole definition (plus #define) through
*/
enum {dump_none = 0, dump_only, dump_names, dump_definitions}
enum
{
dump_none = 0, dump_only, dump_names, dump_definitions
}
dump_macros;
/* Nonzero means pass all #define and #undef directives which we actually
process through to the output stream. This feature is used primarily
to allow cc1 to record the #defines and #undefs for the sake of
debuggers which understand about preprocessor macros, but it may
also be useful with -E to figure out how symbols are defined, and
where they are defined. */
* process through to the output stream. This feature is used primarily
* to allow cc1 to record the #defines and #undefs for the sake of
* debuggers which understand about preprocessor macros, but it may
* also be useful with -E to figure out how symbols are defined, and
* where they are defined. */
int debug_output;
/* Pending -D, -U and -A options, in reverse order. */
struct cpp_pending *pending;
/* File name which deps are being written to.
This is 0 if deps are being written to stdout. */
* This is 0 if deps are being written to stdout. */
char *deps_file;
/* Target-name to write with the dependency information. */
char *deps_target;
};
};
#define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)-> traditional)
#define CPP_PEDANTIC(PFILE) (CPP_OPTIONS (PFILE)->pedantic)
@ -482,17 +492,18 @@ struct cpp_options {
/* Name under which this program was invoked. */
extern char *progname;
extern char *progname;
/* The structure of a node in the hash table. The hash table
has entries for all tokens defined by #define commands (type T_MACRO),
plus some special tokens like __LINE__ (these each have their own
type, and the appropriate code is run when that type of node is seen.
It does not contain control words like "#define", which are recognized
by a separate piece of code. */
* has entries for all tokens defined by #define commands (type T_MACRO),
* plus some special tokens like __LINE__ (these each have their own
* type, and the appropriate code is run when that type of node is seen.
* It does not contain control words like "#define", which are recognized
* by a separate piece of code. */
/* different flavors of hash nodes --- also used in keyword table */
enum node_type {
enum node_type
{
T_DEFINE = 1, /* the `#define' keyword */
T_INCLUDE, /* the `#include' keyword */
T_INCLUDE_NEXT, /* the `#include_next' keyword */
@ -533,37 +544,38 @@ enum node_type {
};
/* Structure returned by create_definition */
typedef struct macrodef MACRODEF;
struct macrodef
{
typedef struct macrodef MACRODEF;
struct macrodef
{
struct definition *defn;
unsigned char *symnam;
int symlen;
};
};
/* Structure allocated for every #define. For a simple replacement
such as
#define foo bar ,
nargs = -1, the `pattern' list is null, and the expansion is just
the replacement text. Nargs = 0 means a functionlike macro with no args,
e.g.,
#define getchar() getc (stdin) .
When there are args, the expansion is the replacement text with the
args squashed out, and the reflist is a list describing how to
build the output from the input: e.g., "3 chars, then the 1st arg,
then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg".
The chars here come from the expansion. Whatever is left of the
expansion after the last arg-occurrence is copied after that arg.
Note that the reflist can be arbitrarily long---
its length depends on the number of times the arguments appear in
the replacement text, not how many args there are. Example:
#define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and
pattern list
{ (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL }
where (x, y) means (nchars, argno). */
* such as
* #define foo bar ,
* nargs = -1, the `pattern' list is null, and the expansion is just
* the replacement text. Nargs = 0 means a functionlike macro with no args,
* e.g.,
* #define getchar() getc (stdin) .
* When there are args, the expansion is the replacement text with the
* args squashed out, and the reflist is a list describing how to
* build the output from the input: e.g., "3 chars, then the 1st arg,
* then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg".
* The chars here come from the expansion. Whatever is left of the
* expansion after the last arg-occurrence is copied after that arg.
* Note that the reflist can be arbitrarily long---
* its length depends on the number of times the arguments appear in
* the replacement text, not how many args there are. Example:
* #define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and
* pattern list
* { (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL }
* where (x, y) means (nchars, argno). */
typedef struct definition DEFINITION;
struct definition {
typedef struct definition DEFINITION;
struct definition
{
int nargs;
int length; /* length of expansion string */
int predefined; /* True if the macro was builtin or */
@ -572,64 +584,69 @@ struct definition {
int line; /* Line number of definition */
char *file; /* File of definition */
char rest_args; /* Nonzero if last arg. absorbs the rest */
struct reflist {
struct reflist
{
struct reflist *next;
char stringify; /* nonzero if this arg was preceded by a
# operator. */
* # operator. */
char raw_before; /* Nonzero if a ## operator before arg. */
char raw_after; /* Nonzero if a ## operator after arg. */
char rest_args; /* Nonzero if this arg. absorbs the rest */
int nchars; /* Number of literal chars to copy before
this arg occurrence. */
* this arg occurrence. */
int argno; /* Number of arg to substitute (origin-0) */
} *pattern;
union {
}
*pattern;
union
{
/* Names of macro args, concatenated in reverse order
with comma-space between them.
The only use of this is that we warn on redefinition
if this differs between the old and new definitions. */
* with comma-space between them.
* The only use of this is that we warn on redefinition
* if this differs between the old and new definitions. */
unsigned char *argnames;
} args;
};
}
args;
};
extern unsigned char is_idchar[256];
extern unsigned char is_idchar[256];
/* 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 */
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 */
* has been passed through rescan */
unsigned char *control_macro; /* For #ifndef at start of file,
this is the macro name tested. */
* this is the macro name tested. */
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_FRAME;
extern void cpp_buf_line_and_col PARAMS((cpp_buffer*, long*, long*));
extern cpp_buffer* cpp_file_buffer PARAMS((cpp_reader*));
extern void cpp_define PARAMS ((cpp_reader*, unsigned char*));
extern void cpp_buf_line_and_col PARAMS((cpp_buffer *, long *, long *));
extern cpp_buffer *cpp_file_buffer PARAMS((cpp_reader *));
extern void cpp_define PARAMS((cpp_reader *, unsigned char *));
extern void cpp_error ();
extern void cpp_warning ();
extern void cpp_pedwarn ();
extern void cpp_error_with_line ();
extern void cpp_pedwarn_with_line ();
extern void cpp_pedwarn_with_file_and_line ();
extern void fatal ();
extern void cpp_error_from_errno ();
extern void cpp_perror_with_name ();
extern void cpp_pfatal_with_name ();
extern void cpp_error();
extern void cpp_warning();
extern void cpp_pedwarn();
extern void cpp_error_with_line();
extern void cpp_pedwarn_with_line();
extern void cpp_pedwarn_with_file_and_line();
extern void fatal();
extern void cpp_error_from_errno();
extern void cpp_perror_with_name();
extern void cpp_pfatal_with_name();
extern void cpp_grow_buffer PARAMS ((cpp_reader*, long));
extern int cpp_parse_escape PARAMS ((cpp_reader*, char**));
extern cpp_buffer* cpp_push_buffer PARAMS ((cpp_reader *, unsigned char*, long));
extern cpp_buffer* cpp_pop_buffer PARAMS ((cpp_reader *));
extern void cpp_grow_buffer PARAMS((cpp_reader *, long));
extern int cpp_parse_escape PARAMS((cpp_reader *, char **));
extern cpp_buffer *cpp_push_buffer PARAMS((cpp_reader *, unsigned char *, long));
extern cpp_buffer *cpp_pop_buffer PARAMS((cpp_reader *));
extern cpp_hashnode* cpp_lookup PARAMS ((cpp_reader*, const unsigned char*,
extern cpp_hashnode *cpp_lookup PARAMS((cpp_reader *, const unsigned char *,
int, int));
#ifdef __EMX__