Wed Oct 27 15:57:32 PDT 1999

(Mandrake)

well crap that didn't work, did it...


SVN revision: 1003
This commit is contained in:
Mandrake 1999-10-27 15:17:20 +00:00
parent 40bcd3daec
commit 539f9ae487
6 changed files with 681 additions and 697 deletions

View File

@ -64,3 +64,10 @@ Wed Oct 27 15:48:58 PDT 1999
Now that we've gone through with -ansi -pedantic and there are no more
warnings, maybe Tru64 support will work in epp?
-------------------------------------------------------------------------------
Wed Oct 27 15:57:32 PDT 1999
(Mandrake)
well crap that didn't work, did it...

View File

@ -317,7 +317,7 @@ cpp_lex(pfile)
case CPP_COMMENT:
goto retry;
case CPP_NUMBER:
return parse_number(pfile, (char *)tok_start, tok_end - tok_start);
return parse_number(pfile, 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);
memcpy((char *)stack, (char *)new_stack, old_size);
bcopy((char *)stack, (char *)new_stack, old_size);
}
stack = new_stack;
top = (struct operation *)((char *)new_stack + old_size);

View File

@ -96,7 +96,7 @@ cpp_lookup(pfile, name, len, hash)
bucket = hashtab[hash];
while (bucket)
{
if (bucket->length == len && strncmp((char *)bucket->name, (char *)name, len) == 0)
if (bucket->length == len && strncmp(bucket->name, name, len) == 0)
return bucket;
bucket = bucket->next;
}

View File

@ -1,21 +1,19 @@
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 */
@ -25,11 +23,11 @@ struct hashnode
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)

View File

@ -87,7 +87,6 @@ char *version_string = "0.0.0";
#if !defined(index) || !defined(_AIX)
extern char *index();
extern char *rindex();
#endif
#ifndef O_RDONLY
@ -581,7 +580,7 @@ quote_string(pfile, src)
CPP_PUTC_Q(pfile, c);
else
{
sprintf((char *)CPP_PWRITTEN(pfile), "\\%03o", c);
sprintf(CPP_PWRITTEN(pfile), "\\%03o", c);
CPP_ADJUST_WRITTEN(pfile, 4);
}
break;
@ -639,7 +638,7 @@ cpp_define(pfile, str)
if (*p == 0)
{
buf = (unsigned char *) alloca(p - buf + 4);
strcpy((char *)buf, (char *)str);
strcpy((char *)buf, str);
strcat((char *)buf, " 1");
}
else if (*p != '=')
@ -652,8 +651,8 @@ cpp_define(pfile, str)
unsigned char *q;
/* Copy the entire option so we can modify it. */
buf = (unsigned char *)alloca(2 * strlen((char *)str) + 1);
strncpy((char *)buf, (char *)str, p - str);
buf = (unsigned char *) alloca(2 * strlen(str) + 1);
strncpy(buf, str, p - str);
/* Change the = to a space. */
buf[p - str] = ' ';
/* Scan for any backslash-newline and remove it. */
@ -669,7 +668,7 @@ cpp_define(pfile, str)
*q = 0;
}
do_define(pfile, NULL, buf, buf + strlen((char *)buf));
do_define(pfile, NULL, buf, buf + strlen(buf));
}
/* Process the string STR as if it appeared as the body of a #assert.
@ -685,8 +684,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((char *)str) + 1);
strcpy((char *)buf, (char *)str);
buf = (unsigned char *) alloca(strlen(str) + 1);
strcpy((char *)buf, str);
/* Scan for any backslash-newline and remove it. */
p = q = buf;
while (*p)
@ -709,7 +708,7 @@ make_assertion(pfile, option, str)
cpp_error(pfile, "malformed option `%s %s'", option, str);
return;
}
ip = cpp_push_buffer(pfile, buf, strlen((char *)buf));
ip = cpp_push_buffer(pfile, buf, strlen(buf));
do_assert(pfile, NULL, NULL, NULL);
cpp_pop_buffer(pfile);
}
@ -785,7 +784,7 @@ deps_output(pfile, string, spacer)
}
if (spacer == ' ' && pfile->deps_column > 0)
pfile->deps_buffer[pfile->deps_size++] = ' ';
memcpy(string, &pfile->deps_buffer[pfile->deps_size], size);
bcopy(string, &pfile->deps_buffer[pfile->deps_size], size);
pfile->deps_size += size;
pfile->deps_column += size;
if (spacer == ':')
@ -826,7 +825,7 @@ path_include(pfile, path)
{
/* Otherwise use the directory that is named. */
name = (char *)xmalloc(q - p + 1);
memcpy(p, name, q - p);
bcopy(p, name, q - p);
name[q - p] = 0;
}
@ -853,7 +852,7 @@ void
init_parse_options(opts)
struct cpp_options *opts;
{
memset((char *)opts, 0, sizeof *opts);
bzero((char *)opts, sizeof *opts);
opts->in_fname = NULL;
opts->out_fname = NULL;
@ -1144,7 +1143,7 @@ handle_directive(pfile)
{
if (kt->length <= 0)
goto not_a_directive;
if (kt->length == ident_length && !strncmp(kt->name, (char *)ident, ident_length))
if (kt->length == ident_length && !strncmp(kt->name, ident, ident_length))
break;
}
@ -1454,7 +1453,7 @@ collect_expansion(pfile, buf, limit, nargs, arglist)
if (arg->name[0] == c
&& arg->length == id_len
&& strncmp((char *)arg->name, (char *)id_beg, id_len) == 0)
&& strncmp(arg->name, id_beg, id_len) == 0)
{
if (expected_delimiter && CPP_OPTIONS(pfile)->warn_stringify)
{
@ -1584,8 +1583,7 @@ 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);
@ -1637,7 +1635,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, (char *)bp, REST_EXTENSION_LENGTH) == 0)
strncmp(rest_extension, bp, REST_EXTENSION_LENGTH) == 0)
{
rest_args = 1;
temp->rest_args = 1;
@ -1669,12 +1667,12 @@ create_definition(buf, limit, pfile, predefinition)
for (otemp = temp->next; otemp != NULL; otemp = otemp->next)
if (temp->length == otemp->length &&
strncmp((char *)temp->name, (char *)otemp->name, temp->length) == 0)
strncmp(temp->name, otemp->name, temp->length) == 0)
{
unsigned char *name;
name = (unsigned char *) alloca(temp->length + 1);
(void)strncpy((char *)name, (char *)temp->name, temp->length);
(void)strncpy(name, temp->name, temp->length);
name[temp->length] = '\0';
cpp_error(pfile,
"duplicate argument name `%s' in `#define'", name);
@ -1699,7 +1697,7 @@ create_definition(buf, limit, pfile, predefinition)
for (temp = arg_ptrs; temp; temp = temp->next)
{
memcpy(temp->name, &defn->args.argnames[i], temp->length);
bcopy(temp->name, &defn->args.argnames[i], temp->length);
i += temp->length;
if (temp->next != 0)
{
@ -1807,13 +1805,13 @@ check_macro_name(pfile, symname, usage)
unsigned char *msg; /* what pain... */
msg = (unsigned char *) alloca(sym_length + 1);
memcpy(symname, msg, sym_length);
bcopy(symname, msg, sym_length);
msg[sym_length] = 0;
cpp_error(pfile, "invalid %s name `%s'", usage, msg);
}
else
{
if (!strncmp((char *)symname, "defined", 7) && sym_length == 7)
if (!strncmp(symname, "defined", 7) && sym_length == 7)
cpp_error(pfile, "invalid %s name `defined'", usage);
}
return sym_length;
@ -1838,7 +1836,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((char *)p1, (char *)p2, a1->nchars))
if (!((a1->nchars == a2->nchars && !strncmp(p1, p2, a1->nchars))
|| !comp_def_part(first, p1, a1->nchars, p2, a2->nchars, 0))
|| a1->argno != a2->argno
|| a1->stringify != a2->stringify
@ -1957,7 +1955,7 @@ do_define(pfile, keyword, buf, limit)
msg = (unsigned char *) alloca(mdef.symlen + 22);
*msg = '`';
memcpy(mdef.symnam, msg + 1, mdef.symlen);
bcopy(mdef.symnam, msg + 1, mdef.symlen);
strcpy((char *)(msg + mdef.symlen + 1), "' redefined");
cpp_pedwarn(pfile, msg);
if (hp->type == T_MACRO)
@ -2020,12 +2018,12 @@ cpp_push_buffer(pfile, buffer, length)
if (buf == pfile->buffer_stack)
fatal("macro or `#include' recursion too deep");
buf--;
memset((char *)buf, 0, sizeof(cpp_buffer));
bzero((char *)buf, sizeof(cpp_buffer));
CPP_BUFFER(pfile) = buf;
#else
register cpp_buffer *buf = (cpp_buffer *) xmalloc(sizeof(cpp_buffer));
memset((char *)buf, 0, sizeof(cpp_buffer));
bzero((char *)buf, sizeof(cpp_buffer));
CPP_PREV_BUFFER(buf) = CPP_BUFFER(pfile);
CPP_BUFFER(pfile) = buf;
#endif
@ -2271,8 +2269,8 @@ output_line_command(pfile, conditional, file_change)
CPP_PUTS_Q(pfile, sharp_line, sizeof(sharp_line) - 1);
}
sprintf((char *)CPP_PWRITTEN(pfile), "%d ", (int)line);
CPP_ADJUST_WRITTEN(pfile, strlen((char *)CPP_PWRITTEN(pfile)));
sprintf(CPP_PWRITTEN(pfile), "%d ", (int)line);
CPP_ADJUST_WRITTEN(pfile, strlen(CPP_PWRITTEN(pfile)));
quote_string(pfile, ip->nominal_fname);
if (file_change != same_file)
@ -2928,8 +2926,7 @@ 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;
@ -3010,7 +3007,7 @@ macroexpand(pfile, hp)
else
{
CPP_RESERVE(pfile, 4);
sprintf((char *)CPP_PWRITTEN(pfile), "\\%03o",
sprintf(CPP_PWRITTEN(pfile), "\\%03o",
(unsigned int)c);
CPP_ADJUST_WRITTEN(pfile, 4);
}
@ -3083,7 +3080,7 @@ macroexpand(pfile, hp)
}
if (ap->stringify != 0)
{
memcpy(ARG_BASE + arg->stringified,
bcopy(ARG_BASE + arg->stringified,
xbuf + totlen, arg->stringified_length);
totlen += arg->stringified_length;
}
@ -3126,7 +3123,7 @@ macroexpand(pfile, hp)
break;
}
}
memcpy(p1, xbuf + totlen, l1 - p1);
bcopy(p1, xbuf + totlen, l1 - p1);
totlen += l1 - p1;
}
else
@ -3140,7 +3137,7 @@ macroexpand(pfile, hp)
xbuf[totlen++] = '@';
xbuf[totlen++] = ' ';
}
memcpy(expanded, xbuf + totlen, arg->expand_length);
bcopy(expanded, xbuf + totlen, arg->expand_length);
totlen += arg->expand_length;
if (!ap->raw_after && totlen > 0 && offset < defn->length
@ -3452,7 +3449,7 @@ do_include(pfile, keyword, unused1, unused2)
if (_fnisabs(fbeg))
#endif
{
strncpy(fname, (char *)fbeg, flen);
strncpy(fname, fbeg, flen);
fname[flen] = 0;
if (redundant_include_p(pfile, fname))
return 0;
@ -3485,7 +3482,7 @@ do_include(pfile, keyword, unused1, unused2)
{
fname[0] = 0;
}
strncat(fname, (char *)fbeg, flen);
strncat(fname, fbeg, flen);
#ifdef VMS
/* Change this 1/2 Unix 1/2 VMS file specification into a
* full VMS file specification */
@ -3530,7 +3527,7 @@ do_include(pfile, keyword, unused1, unused2)
if (f < 0)
{
/* A file that was not found. */
strncpy(fname, (char *)fbeg, flen);
strncpy(fname, 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
@ -3778,7 +3775,7 @@ assertion_lookup(pfile, name, len, hash)
bucket = pfile->assertion_hashtab[hash];
while (bucket)
{
if (bucket->length == len && strncmp((char *)bucket->name, (char *)name, len) == 0)
if (bucket->length == len && strncmp(bucket->name, name, len) == 0)
return bucket;
bucket = bucket->next;
}
@ -3890,7 +3887,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((char *)(pfile->token_buffer + old_written)) - 1;
new_lineno = atoi(pfile->token_buffer + old_written) - 1;
CPP_SET_WRITTEN(pfile, old_written);
/* NEW_LINENO is one less than the actual line number here. */
@ -3959,7 +3956,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, (char *)fname, fname_length) == 0)
strncmp(hp->value.cpval, fname, fname_length) == 0)
{
ip->nominal_fname = hp->value.cpval;
break;
@ -3973,7 +3970,7 @@ do_line(pfile, keyword)
hp->length = fname_length;
ip->nominal_fname = hp->value.cpval = ((char *)hp) + sizeof(HASHNODE);
memcpy(fname, hp->value.cpval, fname_length);
bcopy(fname, hp->value.cpval, fname_length);
}
}
else if (token != CPP_VSPACE && token != CPP_EOF)
@ -4045,7 +4042,7 @@ do_error(pfile, keyword, buf, limit)
unsigned char *copy = (unsigned char *) xmalloc(length + 1);
keyword = NULL;
memcpy(buf, copy, length);
bcopy(buf, copy, length);
copy[length] = 0;
SKIP_WHITE_SPACE(copy);
cpp_error(pfile, "#error %s", copy);
@ -4068,7 +4065,7 @@ do_warning(pfile, keyword, buf, limit)
unsigned char *copy = (unsigned char *) xmalloc(length + 1);
keyword = NULL;
memcpy(buf, copy, length);
bcopy(buf, copy, length);
copy[length] = 0;
SKIP_WHITE_SPACE(copy);
cpp_warning(pfile, "#warning %s", copy);
@ -4141,7 +4138,7 @@ do_pragma(pfile, keyword, buf, limit)
keyword = NULL;
limit = NULL;
if (!strncmp((char *)buf, "once", 4))
if (!strncmp(buf, "once", 4))
{
/* Allow #pragma once in system headers, since that's not the user's
* fault. */
@ -4149,7 +4146,7 @@ do_pragma(pfile, keyword, buf, limit)
cpp_warning(pfile, "`#pragma once' is obsolete");
do_once(pfile);
}
if (!strncmp((char *)buf, "implementation", 14))
if (!strncmp(buf, "implementation", 14))
{
/* Be quiet about `#pragma implementation' for a file only if it hasn't
* been included yet. */
@ -4163,13 +4160,13 @@ do_pragma(pfile, keyword, buf, limit)
fname = p + 1;
p = (unsigned char *) index(fname, '\"');
fname_len = p != NULL ? p - fname : strlen((char *)fname);
fname_len = p != NULL ? p - fname : strlen(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((char *)inc_fname, (char *)fname, fname_len))
if (inc_fname && !strncmp(inc_fname, fname, fname_len))
cpp_warning(pfile,
"`#pragma implementation' for `%s' appears after file is included",
fname);
@ -4333,7 +4330,7 @@ do_xifdef(pfile, keyword, unused1, unused2)
if (start_of_file && !skip)
{
control_macro = (unsigned char *) xmalloc(ident_length + 1);
memcpy(ident, control_macro, ident_length + 1);
bcopy(ident, control_macro, ident_length + 1);
}
}
else
@ -4451,7 +4448,7 @@ skip_if_group(pfile, any)
IF_STACK_FRAME *temp;
if (ident_length == kt->length
&& strncmp((char *)ident, kt->name, kt->length) == 0)
&& strncmp(ident, kt->name, kt->length) == 0)
{
/* If we are asked to return on next directive, do so now. */
if (any)
@ -5279,7 +5276,7 @@ cpp_get_token(pfile)
xbuf_len = CPP_WRITTEN(pfile) - before_name_written;
xbuf = (unsigned char *) xmalloc(xbuf_len + 1);
CPP_SET_WRITTEN(pfile, before_name_written);
memcpy(CPP_PWRITTEN(pfile), xbuf, xbuf_len + 1);
bcopy(CPP_PWRITTEN(pfile), xbuf, xbuf_len + 1);
push_macro_expansion(pfile, xbuf, xbuf_len, hp);
}
else
@ -5472,7 +5469,7 @@ lookup_import(pfile, filename, searchptr)
{
/* Compare the inode and the device.
* Supposedly on some systems the inode is not a scalar. */
if (!memcmp((char *)&i->inode, (char *)&sb.st_ino, sizeof(sb.st_ino))
if (!bcmp((char *)&i->inode, (char *)&sb.st_ino, sizeof(sb.st_ino))
&& i->dev == sb.st_dev)
{
close(fd);
@ -5503,7 +5500,7 @@ add_import(pfile, fd, fname)
i->name = (char *)xmalloc(strlen(fname) + 1);
strcpy(i->name, fname);
memcpy((char *)&sb.st_ino, (char *)&i->inode, sizeof(sb.st_ino));
bcopy((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;
@ -5712,7 +5709,7 @@ open_include_file(pfile, filename, searchptr)
else
{
dir = (char *)alloca(p - filename + 1);
memcpy(filename, dir, p - filename);
bcopy(filename, dir, p - filename);
dir[p - filename] = '\0';
from = p + 1;
}
@ -5772,7 +5769,7 @@ finclude(pfile, f, fname, system_header_p, dirptr)
/* Read the file contents, knowing that st_size is an upper bound
* on the number of bytes we can read. */
length = safe_read(f, (char *)fp->buf, st_size);
length = safe_read(f, fp->buf, st_size);
fp->rlimit = fp->buf + length;
if (length < 0)
goto nope;
@ -5796,7 +5793,7 @@ finclude(pfile, f, fname, system_header_p, dirptr)
for (;;)
{
i = safe_read(f, (char *)fp->buf + st_size, bsize - st_size);
i = safe_read(f, fp->buf + st_size, bsize - st_size);
if (i < 0)
goto nope; /* error! */
st_size += i;
@ -5901,7 +5898,7 @@ push_parse_file(pfile, fname)
*p++ = 0;
if (opts->debug_output)
output_line_command(pfile, 0, same_file);
cpp_define(pfile, (unsigned char *)q);
cpp_define(pfile, q);
while (*p == ' ' || *p == '\t')
p++;
}
@ -5972,13 +5969,12 @@ push_parse_file(pfile, fname)
case 'U':
if (opts->debug_output)
output_line_command(pfile, 0, same_file);
do_undef(pfile, NULL, (unsigned char *)pend->arg,
(unsigned char *)pend->arg + strlen(pend->arg));
do_undef(pfile, NULL, pend->arg, pend->arg + strlen(pend->arg));
break;
case 'D':
if (opts->debug_output)
output_line_command(pfile, 0, same_file);
cpp_define(pfile, (unsigned char *)pend->arg);
cpp_define(pfile, pend->arg);
break;
case 'A':
make_assertion(pfile, "-A", pend->arg);
@ -6050,7 +6046,7 @@ push_parse_file(pfile, fname)
endp++;
}
/* Put the usual defaults back in at the end. */
memcpy((char *)include_defaults_array,
bcopy((char *)include_defaults_array,
(char *)&include_defaults[num_dirs],
sizeof(include_defaults_array));
}
@ -6215,7 +6211,7 @@ push_parse_file(pfile, fname)
{
opts->deps_target = s + 1;
output_file = (char *)xmalloc(s - spec + 1);
memcpy(spec, output_file, s - spec);
bcopy(spec, output_file, s - spec);
output_file[s - spec] = 0;
}
else
@ -6335,7 +6331,7 @@ init_parse_file(pfile)
cpp_reader *pfile;
{
memset((char *)pfile, 0, sizeof(cpp_reader));
bzero((char *)pfile, sizeof(cpp_reader));
pfile->get_token = cpp_get_token;
pfile->token_buffer_size = 200;
@ -6968,7 +6964,7 @@ do_assert(pfile, keyword, buf, limit)
hp = assertion_lookup(pfile, symname, sym_length, hashcode);
if (hp == NULL)
{
if (sym_length == 7 && !strncmp((char *)symname, "defined", sym_length))
if (sym_length == 7 && !strncmp(symname, "defined", sym_length))
cpp_error(pfile, "`defined' redefined as assertion");
hp = assertion_install(pfile, symname, sym_length, hashcode);
}
@ -7145,7 +7141,7 @@ compare_token_lists(l1, l2)
{
if (l1->length != l2->length)
return 0;
if (strncmp((char *)l1->name, (char *)l2->name, l1->length))
if (strncmp(l1->name, l2->name, l1->length))
return 0;
l1 = l1->next;
l2 = l2->next;
@ -7236,7 +7232,7 @@ read_token_list(pfile, error_flag)
xmalloc(sizeof(struct arglist) + length + 1);
temp->name = (unsigned char *) (temp + 1);
memcpy((char *)(pfile->token_buffer + name_written),
bcopy((char *)(pfile->token_buffer + name_written),
(char *)temp->name, length);
temp->name[length] = 0;
temp->next = token_ptrs;

View File

@ -1,32 +1,30 @@
/* 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
@ -37,8 +35,7 @@ extern "C"
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,
@ -72,10 +69,9 @@ extern "C"
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;
@ -91,12 +87,12 @@ extern "C"
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;
@ -106,8 +102,7 @@ extern "C"
/* 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 */
@ -119,7 +114,7 @@ extern "C"
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;
@ -133,7 +128,7 @@ extern "C"
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>. */
@ -141,12 +136,12 @@ extern "C"
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;
};
@ -158,12 +153,11 @@ extern "C"
#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;
@ -187,12 +181,12 @@ extern "C"
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. */
@ -201,12 +195,12 @@ extern "C"
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. */
@ -222,16 +216,16 @@ extern "C"
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;
@ -270,9 +264,9 @@ extern "C"
&& (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) \
(memcpy (STR, (PFILE)->limit, (N)), (PFILE)->limit += (N))
(bcopy (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. */
@ -296,8 +290,7 @@ extern "C"
#endif
/* Pointed to by parse_file::data. */
struct cpp_options
{
struct cpp_options {
char *in_fname;
/* Name of output file, for error messages. */
@ -321,7 +314,7 @@ extern "C"
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;
@ -330,7 +323,7 @@ extern "C"
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;
@ -343,13 +336,13 @@ extern "C"
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;
@ -381,7 +374,7 @@ extern "C"
char warn_import;
/* Nonzero means warn if a macro argument is (or would be)
* stringified with -traditional. */
stringified with -traditional. */
char warn_stringify;
@ -390,8 +383,8 @@ extern "C"
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;
@ -400,21 +393,21 @@ extern "C"
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
@ -431,10 +424,10 @@ extern "C"
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 */
@ -447,7 +440,7 @@ extern "C"
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;
@ -455,31 +448,28 @@ extern "C"
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. */
@ -495,15 +485,14 @@ extern "C"
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 */
@ -553,29 +542,28 @@ extern "C"
};
/* 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
{
struct definition {
int nargs;
int length; /* length of expansion string */
int predefined; /* True if the macro was builtin or */
@ -584,44 +572,39 @@ extern "C"
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];
/* 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;