Commit 7ceb3598 by Neil Booth Committed by Neil Booth

cppfiles.c (file_cleanup, [...]): Replace bcopy(), index() etc calls.

	* cppfiles.c (file_cleanup, _cpp_find_include_file,
	remap_filename, _cpp_read_include_file, actual_directory,
	hack_vms_include_specification): Replace bcopy(), index() etc
	calls.  Add casts to some allocations.  Make some variables
 	pointers to const [unsigned] char.
	* cpphash.c (_cpp_install, macro_cleanup, collect_expansion,
	collect_formal_parameters): Similarly.
	* cppinit.c (struct pending_option, append_include_chain,
	cpp_options_init, cpp_reader_init, initialize_standard_includes,
	cpp_start_read, new_pending_define, handle_option): Similarly.
	* cpplib.c (cpp_define, copy_comment, do_define, do_include,
	do_undef, do_error, do_warning, do_pragma, do_pragma_once,
	do_pragma_implementation, detect_if_not_defined,
	do_ifdef, skip_if_group, cpp_get_token, parse_string,
	do_assert, do_unassert): Similarly.
	* cpplib.h (cpp_buffer, cpp_options): Update types.  Update
	function prototypes.
	* mkdeps.c (deps_add_target, deps_add_dep): cast allocations.

From-SVN: r32477
parent fca9f642
2000-03-11 Neil Booth <NeilB@earthling.net>
* cppfiles.c (file_cleanup, _cpp_find_include_file,
remap_filename, _cpp_read_include_file, actual_directory,
hack_vms_include_specification): Replace bcopy(), index() etc
calls. Add casts to some allocations. Make some variables
pointers to const [unsigned] char.
* cpphash.c (_cpp_install, macro_cleanup, collect_expansion,
collect_formal_parameters): Similarly.
* cppinit.c (struct pending_option, append_include_chain,
cpp_options_init, cpp_reader_init, initialize_standard_includes,
cpp_start_read, new_pending_define, handle_option): Similarly.
* cpplib.c (cpp_define, copy_comment, do_define, do_include,
do_undef, do_error, do_warning, do_pragma, do_pragma_once,
do_pragma_implementation, detect_if_not_defined,
do_ifdef, skip_if_group, cpp_get_token, parse_string,
do_assert, do_unassert): Similarly.
* cpplib.h (cpp_buffer, cpp_options): Update types. Update
function prototypes.
* mkdeps.c (deps_add_target, deps_add_dep): cast allocations.
2000-03-10 Richard Henderson <rth@cygnus.com> 2000-03-10 Richard Henderson <rth@cygnus.com>
* builtins.c (expand_builtin_strlen): Revert last change. * builtins.c (expand_builtin_strlen): Revert last change.
......
...@@ -165,7 +165,7 @@ file_cleanup (pbuf, pfile) ...@@ -165,7 +165,7 @@ file_cleanup (pbuf, pfile)
{ {
if (pbuf->buf) if (pbuf->buf)
{ {
free (pbuf->buf); free ((PTR) pbuf->buf);
pbuf->buf = 0; pbuf->buf = 0;
} }
if (pfile->system_include_depth) if (pfile->system_include_depth)
...@@ -246,7 +246,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before) ...@@ -246,7 +246,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before)
for (l = search_start; l; l = l->next) for (l = search_start; l; l = l->next)
{ {
bcopy (l->name, name, l->nlen); memcpy (name, l->name, l->nlen);
name[l->nlen] = '/'; name[l->nlen] = '/';
strcpy (&name[l->nlen+1], fname); strcpy (&name[l->nlen+1], fname);
_cpp_simplify_pathname (name); _cpp_simplify_pathname (name);
...@@ -266,7 +266,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before) ...@@ -266,7 +266,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before)
if (f >= 0) if (f >= 0)
{ {
ih->foundhere = l; ih->foundhere = l;
ih->name = xrealloc (name, strlen (name)+1); ih->name = xrealloc (name, strlen (name) + 1);
return f; return f;
} }
} }
...@@ -445,7 +445,7 @@ remap_filename (pfile, name, loc) ...@@ -445,7 +445,7 @@ remap_filename (pfile, name, loc)
looking in. Thus #include <sys/types.h> will look up sys/types.h looking in. Thus #include <sys/types.h> will look up sys/types.h
in /usr/include/header.gcc and look up types.h in in /usr/include/header.gcc and look up types.h in
/usr/include/sys/header.gcc. */ /usr/include/sys/header.gcc. */
p = rindex (name, '/'); p = strrchr (name, '/');
if (!p) if (!p)
p = name; p = name;
if (loc && loc->name if (loc && loc->name
...@@ -462,7 +462,7 @@ remap_filename (pfile, name, loc) ...@@ -462,7 +462,7 @@ remap_filename (pfile, name, loc)
else else
{ {
char * newdir = (char *) alloca (p - name + 1); char * newdir = (char *) alloca (p - name + 1);
bcopy (name, newdir, p - name); memcpy (newdir, name, p - name);
newdir[p - name] = '\0'; newdir[p - name] = '\0';
dir = newdir; dir = newdir;
from = p + 1; from = p + 1;
...@@ -614,7 +614,7 @@ _cpp_read_include_file (pfile, fd, ihash) ...@@ -614,7 +614,7 @@ _cpp_read_include_file (pfile, fd, ihash)
if (length < 0) if (length < 0)
goto fail; goto fail;
if (length == 0) if (length == 0)
ihash->control_macro = ""; /* never re-include */ ihash->control_macro = (const U_CHAR *) ""; /* never re-include */
close (fd); close (fd);
fp->rlimit = fp->alimit = fp->buf + length; fp->rlimit = fp->alimit = fp->buf + length;
...@@ -657,7 +657,7 @@ actual_directory (pfile, fname) ...@@ -657,7 +657,7 @@ actual_directory (pfile, fname)
struct file_name_list *x; struct file_name_list *x;
dir = xstrdup (fname); dir = xstrdup (fname);
last_slash = rindex (dir, '/'); last_slash = strrchr (dir, '/');
if (last_slash) if (last_slash)
{ {
if (last_slash == dir) if (last_slash == dir)
...@@ -1266,20 +1266,20 @@ hack_vms_include_specification (fullname) ...@@ -1266,20 +1266,20 @@ hack_vms_include_specification (fullname)
check_filename_before_returning = 0; check_filename_before_returning = 0;
must_revert = 0; must_revert = 0;
/* See if we can find a 1st slash. If not, there's no path information. */ /* See if we can find a 1st slash. If not, there's no path information. */
first_slash = index (fullname, '/'); first_slash = strchr (fullname, '/');
if (first_slash == 0) if (first_slash == 0)
return 0; /* Nothing to do!!! */ return 0; /* Nothing to do!!! */
/* construct device spec if none given. */ /* construct device spec if none given. */
if (index (fullname, ':') == 0) if (strchr (fullname, ':') == 0)
{ {
/* If fullname has a slash, take it as device spec. */ /* If fullname has a slash, take it as device spec. */
if (first_slash == fullname) if (first_slash == fullname)
{ {
first_slash = index (fullname+1, '/'); /* 2nd slash ? */ first_slash = strchr (fullname + 1, '/'); /* 2nd slash ? */
if (first_slash) if (first_slash)
*first_slash = ':'; /* make device spec */ *first_slash = ':'; /* make device spec */
for (basename = fullname; *basename != 0; basename++) for (basename = fullname; *basename != 0; basename++)
...@@ -1399,7 +1399,7 @@ hack_vms_include_specification (fullname) ...@@ -1399,7 +1399,7 @@ hack_vms_include_specification (fullname)
in the "root" directory. Otherwise, we need to add in the "root" directory. Otherwise, we need to add
directory specifications. */ directory specifications. */
if (index (unixname, '/') == 0) if (strchr (unixname, '/') == 0)
{ {
/* if no directories specified yet and none are following. */ /* if no directories specified yet and none are following. */
if (local_ptr[-1] == '[') if (local_ptr[-1] == '[')
...@@ -1414,7 +1414,7 @@ hack_vms_include_specification (fullname) ...@@ -1414,7 +1414,7 @@ hack_vms_include_specification (fullname)
{ {
/* As long as there are still subdirectories to add, do them. */ /* As long as there are still subdirectories to add, do them. */
while (index (unixname, '/') != 0) while (strchr (unixname, '/') != 0)
{ {
/* If this token is "." we can ignore it /* If this token is "." we can ignore it
if it's not at the beginning of a path. */ if it's not at the beginning of a path. */
...@@ -1496,8 +1496,8 @@ hack_vms_include_specification (fullname) ...@@ -1496,8 +1496,8 @@ hack_vms_include_specification (fullname)
/* The filename did not work. Try to remove the [000000] from the name, /* The filename did not work. Try to remove the [000000] from the name,
and return it. */ and return it. */
basename = index (fullname, '['); basename = strchr (fullname, '[');
local_ptr = index (fullname, ']') + 1; local_ptr = strchr (fullname, ']') + 1;
strcpy (basename, local_ptr); /* this gets rid of it */ strcpy (basename, local_ptr); /* this gets rid of it */
} }
......
...@@ -237,7 +237,7 @@ _cpp_install (pfile, name, len, type, value) ...@@ -237,7 +237,7 @@ _cpp_install (pfile, name, len, type, value)
hp->length = len; hp->length = len;
hp->value.cpval = value; hp->value.cpval = value;
hp->name = ((U_CHAR *) hp) + sizeof (HASHNODE); hp->name = ((U_CHAR *) hp) + sizeof (HASHNODE);
bcopy (name, hp->name, len); memcpy (hp->name, name, len);
hp->name[len] = 0; hp->name[len] = 0;
return hp; return hp;
} }
...@@ -251,7 +251,7 @@ macro_cleanup (pbuf, pfile) ...@@ -251,7 +251,7 @@ macro_cleanup (pbuf, pfile)
if (macro->type == T_DISABLED) if (macro->type == T_DISABLED)
macro->type = T_MACRO; macro->type = T_MACRO;
if (macro->type != T_MACRO || pbuf->buf != macro->value.defn->expansion) if (macro->type != T_MACRO || pbuf->buf != macro->value.defn->expansion)
free (pbuf->buf); free ((PTR) pbuf->buf);
return 0; return 0;
} }
...@@ -493,7 +493,7 @@ collect_expansion (pfile, arglist) ...@@ -493,7 +493,7 @@ collect_expansion (pfile, arglist)
if (last_token == START) if (last_token == START)
{ {
/* Empty macro definition. */ /* Empty macro definition. */
exp = xstrdup ("\r \r "); exp = (U_CHAR *) xstrdup ("\r \r ");
len = 1; len = 1;
} }
else else
...@@ -506,7 +506,8 @@ collect_expansion (pfile, arglist) ...@@ -506,7 +506,8 @@ collect_expansion (pfile, arglist)
CPP_NUL_TERMINATE (pfile); CPP_NUL_TERMINATE (pfile);
len = CPP_WRITTEN (pfile) - start + 1; len = CPP_WRITTEN (pfile) - start + 1;
exp = xmalloc (len + 4); /* space for no-concat markers at either end */ /* space for no-concat markers at either end */
exp = (U_CHAR *) xmalloc (len + 4);
exp[0] = '\r'; exp[0] = '\r';
exp[1] = ' '; exp[1] = ' ';
exp[len + 1] = '\r'; exp[len + 1] = '\r';
...@@ -580,7 +581,7 @@ collect_formal_parameters (pfile) ...@@ -580,7 +581,7 @@ collect_formal_parameters (pfile)
tok = pfile->token_buffer + old_written; tok = pfile->token_buffer + old_written;
len = CPP_PWRITTEN (pfile) - tok; len = CPP_PWRITTEN (pfile) - tok;
if (namebuf if (namebuf
&& (name = strstr (namebuf, tok)) && (name = (U_CHAR *) strstr (namebuf, tok))
&& name[len] == ',' && name[len] == ','
&& (name == namebuf || name[-1] == ',')) && (name == namebuf || name[-1] == ','))
{ {
...@@ -591,7 +592,7 @@ collect_formal_parameters (pfile) ...@@ -591,7 +592,7 @@ collect_formal_parameters (pfile)
&& !strncmp (tok, "__VA_ARGS__", sizeof "__VA_ARGS__" - 1)) && !strncmp (tok, "__VA_ARGS__", sizeof "__VA_ARGS__" - 1))
cpp_pedwarn (pfile, cpp_pedwarn (pfile,
"C99 does not permit use of `__VA_ARGS__' as a macro argument name"); "C99 does not permit use of `__VA_ARGS__' as a macro argument name");
namebuf = xrealloc (namebuf, argslen + len + 1); namebuf = (U_CHAR *) xrealloc (namebuf, argslen + len + 1);
name = &namebuf[argslen - 1]; name = &namebuf[argslen - 1];
argslen += len + 1; argslen += len + 1;
...@@ -604,7 +605,7 @@ collect_formal_parameters (pfile) ...@@ -604,7 +605,7 @@ collect_formal_parameters (pfile)
case CPP_COMMA: case CPP_COMMA:
argc++; argc++;
argv = xrealloc (argv, (argc + 1)*sizeof(struct arg)); argv = (struct arg *) xrealloc (argv, (argc + 1)*sizeof(struct arg));
argv[argc].len = 0; argv[argc].len = 0;
break; break;
...@@ -637,7 +638,7 @@ collect_formal_parameters (pfile) ...@@ -637,7 +638,7 @@ collect_formal_parameters (pfile)
cpp_pedwarn (pfile, "C89 does not permit varargs macros"); cpp_pedwarn (pfile, "C89 does not permit varargs macros");
len = sizeof "__VA_ARGS__" - 1; len = sizeof "__VA_ARGS__" - 1;
namebuf = xrealloc (namebuf, argslen + len + 1); namebuf = (U_CHAR *) xrealloc (namebuf, argslen + len + 1);
name = &namebuf[argslen - 1]; name = &namebuf[argslen - 1];
argslen += len; argslen += len;
memcpy (name, "__VA_ARGS__", len); memcpy (name, "__VA_ARGS__", len);
......
...@@ -167,7 +167,7 @@ static const struct default_include include_defaults_array[] ...@@ -167,7 +167,7 @@ static const struct default_include include_defaults_array[]
struct pending_option struct pending_option
{ {
struct pending_option *next; struct pending_option *next;
char *arg; const char *arg;
int undef; int undef;
}; };
...@@ -354,7 +354,7 @@ append_include_chain (pfile, pend, dir, path, cxx_aware) ...@@ -354,7 +354,7 @@ append_include_chain (pfile, pend, dir, path, cxx_aware)
if (len > pfile->max_include_len) if (len > pfile->max_include_len)
pfile->max_include_len = len; pfile->max_include_len = len;
new = (struct file_name_list *)xmalloc (sizeof (struct file_name_list)); new = (struct file_name_list *) xmalloc (sizeof (struct file_name_list));
new->name = dir; new->name = dir;
new->nlen = len; new->nlen = len;
new->ino = st.st_ino; new->ino = st.st_ino;
...@@ -530,7 +530,7 @@ void ...@@ -530,7 +530,7 @@ void
cpp_options_init (opts) cpp_options_init (opts)
cpp_options *opts; cpp_options *opts;
{ {
bzero ((char *) opts, sizeof (struct cpp_options)); memset ((char *) opts, 0, sizeof (struct cpp_options));
opts->dollars_in_ident = 1; opts->dollars_in_ident = 1;
opts->cplusplus_comments = 1; opts->cplusplus_comments = 1;
...@@ -546,7 +546,7 @@ void ...@@ -546,7 +546,7 @@ void
cpp_reader_init (pfile) cpp_reader_init (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
bzero ((char *) pfile, sizeof (cpp_reader)); memset ((char *) pfile, 0, sizeof (cpp_reader));
pfile->token_buffer_size = 200; pfile->token_buffer_size = 200;
pfile->token_buffer = (U_CHAR *) xmalloc (pfile->token_buffer_size); pfile->token_buffer = (U_CHAR *) xmalloc (pfile->token_buffer_size);
...@@ -747,7 +747,7 @@ initialize_standard_includes (pfile) ...@@ -747,7 +747,7 @@ initialize_standard_includes (pfile)
cpp_options *opts = CPP_OPTIONS (pfile); cpp_options *opts = CPP_OPTIONS (pfile);
char *path; char *path;
const struct default_include *p; const struct default_include *p;
char *specd_prefix = opts->include_prefix; const char *specd_prefix = opts->include_prefix;
/* Several environment variables may add to the include search path. /* Several environment variables may add to the include search path.
CPATH specifies an additional list of directories to be searched CPATH specifies an additional list of directories to be searched
...@@ -841,7 +841,7 @@ initialize_standard_includes (pfile) ...@@ -841,7 +841,7 @@ initialize_standard_includes (pfile)
int int
cpp_start_read (pfile, fname) cpp_start_read (pfile, fname)
cpp_reader *pfile; cpp_reader *pfile;
char *fname; const char *fname;
{ {
struct cpp_options *opts = CPP_OPTIONS (pfile); struct cpp_options *opts = CPP_OPTIONS (pfile);
struct pending_option *p, *q; struct pending_option *p, *q;
...@@ -1054,7 +1054,7 @@ new_pending_define (opts, text) ...@@ -1054,7 +1054,7 @@ new_pending_define (opts, text)
struct pending_option *o = (struct pending_option *) struct pending_option *o = (struct pending_option *)
xmalloc (sizeof (struct pending_option)); xmalloc (sizeof (struct pending_option));
o->arg = (char *) text; o->arg = text;
o->next = NULL; o->next = NULL;
o->undef = 0; o->undef = 0;
APPEND (opts->pending, define, o); APPEND (opts->pending, define, o);
...@@ -1268,7 +1268,7 @@ handle_option (pfile, argc, argv) ...@@ -1268,7 +1268,7 @@ handle_option (pfile, argc, argv)
{ {
enum opt_code opt_code; enum opt_code opt_code;
int opt_index; int opt_index;
char *arg = 0; const char *arg = 0;
/* Skip over '-' */ /* Skip over '-' */
opt_index = parse_option (&argv[i][1]); opt_index = parse_option (&argv[i][1]);
......
...@@ -214,9 +214,9 @@ cpp_grow_buffer (pfile, n) ...@@ -214,9 +214,9 @@ cpp_grow_buffer (pfile, n)
void void
cpp_define (pfile, str) cpp_define (pfile, str)
cpp_reader *pfile; cpp_reader *pfile;
U_CHAR *str; const char *str;
{ {
U_CHAR *buf, *p; char *buf, *p;
size_t count; size_t count;
p = strchr (str, '='); p = strchr (str, '=');
...@@ -227,7 +227,7 @@ cpp_define (pfile, str) ...@@ -227,7 +227,7 @@ cpp_define (pfile, str)
if (p) if (p)
{ {
count = strlen (str) + 2; count = strlen (str) + 2;
buf = (U_CHAR *) alloca (count); buf = alloca (count);
memcpy (buf, str, count - 2); memcpy (buf, str, count - 2);
buf[p - str] = ' '; buf[p - str] = ' ';
buf[count - 2] = '\n'; buf[count - 2] = '\n';
...@@ -236,7 +236,7 @@ cpp_define (pfile, str) ...@@ -236,7 +236,7 @@ cpp_define (pfile, str)
else else
{ {
count = strlen (str) + 4; count = strlen (str) + 4;
buf = (U_CHAR *) alloca (count); buf = alloca (count);
memcpy (buf, str, count - 4); memcpy (buf, str, count - 4);
strcpy (&buf[count-4], " 1\n"); strcpy (&buf[count-4], " 1\n");
} }
...@@ -252,7 +252,7 @@ cpp_define (pfile, str) ...@@ -252,7 +252,7 @@ cpp_define (pfile, str)
void void
cpp_assert (pfile, str) cpp_assert (pfile, str)
cpp_reader *pfile; cpp_reader *pfile;
U_CHAR *str; const char *str;
{ {
if (cpp_push_buffer (pfile, str, strlen (str)) != NULL) if (cpp_push_buffer (pfile, str, strlen (str)) != NULL)
{ {
...@@ -409,8 +409,8 @@ copy_comment (pfile, m) ...@@ -409,8 +409,8 @@ copy_comment (pfile, m)
cpp_reader *pfile; cpp_reader *pfile;
int m; int m;
{ {
U_CHAR *start = CPP_BUFFER (pfile)->cur; /* XXX Layering violation */ const U_CHAR *start = CPP_BUFFER (pfile)->cur; /* XXX Layering violation */
U_CHAR *limit; const U_CHAR *limit;
if (skip_comment (pfile, m) == m) if (skip_comment (pfile, m) == m)
return m; return m;
...@@ -749,7 +749,7 @@ do_define (pfile, keyword) ...@@ -749,7 +749,7 @@ do_define (pfile, keyword)
cpp_buffer * cpp_buffer *
cpp_push_buffer (pfile, buffer, length) cpp_push_buffer (pfile, buffer, length)
cpp_reader *pfile; cpp_reader *pfile;
U_CHAR *buffer; const U_CHAR *buffer;
long length; long length;
{ {
cpp_buffer *buf = CPP_BUFFER (pfile); cpp_buffer *buf = CPP_BUFFER (pfile);
...@@ -1258,7 +1258,7 @@ do_include (pfile, keyword) ...@@ -1258,7 +1258,7 @@ do_include (pfile, keyword)
/* Actually process the file */ /* Actually process the file */
if (importing) if (importing)
ihash->control_macro = ""; ihash->control_macro = (const U_CHAR *) "";
if (cpp_push_buffer (pfile, NULL, 0) == NULL) if (cpp_push_buffer (pfile, NULL, 0) == NULL)
{ {
...@@ -1491,11 +1491,11 @@ do_undef (pfile, keyword) ...@@ -1491,11 +1491,11 @@ do_undef (pfile, keyword)
void void
cpp_undef (pfile, macro) cpp_undef (pfile, macro)
cpp_reader *pfile; cpp_reader *pfile;
U_CHAR *macro; const char *macro;
{ {
/* Copy the string so we can append a newline. */ /* Copy the string so we can append a newline. */
size_t len = strlen (macro); size_t len = strlen (macro);
U_CHAR *buf = alloca (len + 2); char *buf = alloca (len + 2);
memcpy (buf, macro, len); memcpy (buf, macro, len);
buf[len] = '\n'; buf[len] = '\n';
buf[len + 1] = '\0'; buf[len + 1] = '\0';
...@@ -1517,7 +1517,7 @@ do_error (pfile, keyword) ...@@ -1517,7 +1517,7 @@ do_error (pfile, keyword)
cpp_reader *pfile; cpp_reader *pfile;
const struct directive *keyword ATTRIBUTE_UNUSED; const struct directive *keyword ATTRIBUTE_UNUSED;
{ {
U_CHAR *text, *limit; const U_CHAR *text, *limit;
cpp_skip_hspace (pfile); cpp_skip_hspace (pfile);
text = CPP_BUFFER (pfile)->cur; text = CPP_BUFFER (pfile)->cur;
...@@ -1538,7 +1538,7 @@ do_warning (pfile, keyword) ...@@ -1538,7 +1538,7 @@ do_warning (pfile, keyword)
cpp_reader *pfile; cpp_reader *pfile;
const struct directive *keyword ATTRIBUTE_UNUSED; const struct directive *keyword ATTRIBUTE_UNUSED;
{ {
U_CHAR *text, *limit; const U_CHAR *text, *limit;
cpp_skip_hspace (pfile); cpp_skip_hspace (pfile);
text = CPP_BUFFER (pfile)->cur; text = CPP_BUFFER (pfile)->cur;
...@@ -1626,7 +1626,7 @@ do_pragma (pfile, keyword) ...@@ -1626,7 +1626,7 @@ do_pragma (pfile, keyword)
buf = pfile->token_buffer + key; buf = pfile->token_buffer + key;
CPP_PUTC (pfile, ' '); CPP_PUTC (pfile, ' ');
#define tokis(x) !strncmp(buf, x, sizeof(x) - 1) #define tokis(x) !strncmp((char *) buf, x, sizeof(x) - 1)
if (tokis ("once")) if (tokis ("once"))
pop = do_pragma_once (pfile); pop = do_pragma_once (pfile);
else if (tokis ("implementation")) else if (tokis ("implementation"))
...@@ -1677,7 +1677,7 @@ do_pragma_once (pfile) ...@@ -1677,7 +1677,7 @@ do_pragma_once (pfile)
if (CPP_PREV_BUFFER (ip) == NULL) if (CPP_PREV_BUFFER (ip) == NULL)
cpp_warning (pfile, "`#pragma once' outside include file"); cpp_warning (pfile, "`#pragma once' outside include file");
else else
ip->ihash->control_macro = ""; /* never repeat */ ip->ihash->control_macro = (const U_CHAR *) ""; /* never repeat */
return 1; return 1;
} }
...@@ -1703,7 +1703,7 @@ do_pragma_implementation (pfile) ...@@ -1703,7 +1703,7 @@ do_pragma_implementation (pfile)
} }
name = pfile->token_buffer + written + 1; name = pfile->token_buffer + written + 1;
copy = xstrdup (name); copy = (U_CHAR *) xstrdup (name);
copy[strlen(copy)] = '\0'; /* trim trailing quote */ copy[strlen(copy)] = '\0'; /* trim trailing quote */
if (cpp_included (pfile, copy)) if (cpp_included (pfile, copy))
...@@ -1844,7 +1844,7 @@ detect_if_not_defined (pfile) ...@@ -1844,7 +1844,7 @@ detect_if_not_defined (pfile)
if ((!need_rparen || get_directive_token (pfile) == CPP_RPAREN) if ((!need_rparen || get_directive_token (pfile) == CPP_RPAREN)
/* ...and make sure there's nothing else on the line. */ /* ...and make sure there's nothing else on the line. */
&& get_directive_token (pfile) == CPP_VSPACE) && get_directive_token (pfile) == CPP_VSPACE)
control_macro = xstrdup (ident); control_macro = (U_CHAR *) xstrdup (ident);
restore: restore:
CPP_SET_WRITTEN (pfile, base_offset); CPP_SET_WRITTEN (pfile, base_offset);
...@@ -1980,7 +1980,7 @@ do_ifdef (pfile, keyword) ...@@ -1980,7 +1980,7 @@ do_ifdef (pfile, keyword)
if (start_of_file && !skip) if (start_of_file && !skip)
{ {
control_macro = (U_CHAR *) xmalloc (ident_length + 1); control_macro = (U_CHAR *) xmalloc (ident_length + 1);
bcopy (ident, control_macro, ident_length + 1); memcpy (control_macro, ident, ident_length + 1);
} }
} }
else else
...@@ -2114,7 +2114,7 @@ skip_if_group (pfile) ...@@ -2114,7 +2114,7 @@ skip_if_group (pfile)
{ {
int c; int c;
IF_STACK *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; const U_CHAR *beg_of_line;
long old_written; long old_written;
old_written = CPP_WRITTEN (pfile); old_written = CPP_WRITTEN (pfile);
...@@ -2674,7 +2674,7 @@ cpp_get_token (pfile) ...@@ -2674,7 +2674,7 @@ cpp_get_token (pfile)
while (CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile))) while (CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile)))
{ {
U_CHAR *point = CPP_BUFFER (pfile)->cur; const U_CHAR *point = CPP_BUFFER (pfile)->cur;
for (;;) for (;;)
{ {
cpp_skip_hspace (pfile); cpp_skip_hspace (pfile);
...@@ -2929,8 +2929,8 @@ parse_string (pfile, c) ...@@ -2929,8 +2929,8 @@ parse_string (pfile, c)
cpp_reader *pfile; cpp_reader *pfile;
int c; int c;
{ {
U_CHAR *start = CPP_BUFFER (pfile)->cur; /* XXX Layering violation */ const U_CHAR *start = CPP_BUFFER (pfile)->cur; /* XXX Layering violation */
U_CHAR *limit; const U_CHAR *limit;
skip_string (pfile, c); skip_string (pfile, c);
...@@ -3050,7 +3050,7 @@ do_assert (pfile, keyword) ...@@ -3050,7 +3050,7 @@ do_assert (pfile, keyword)
} }
thislen = strlen (sym); thislen = strlen (sym);
baselen = (U_CHAR *) index (sym, '(') - sym; baselen = (U_CHAR *) strchr (sym, '(') - sym;
this = _cpp_lookup (pfile, sym, thislen); this = _cpp_lookup (pfile, sym, thislen);
if (this) if (this)
{ {
...@@ -3124,7 +3124,7 @@ do_unassert (pfile, keyword) ...@@ -3124,7 +3124,7 @@ do_unassert (pfile, keyword)
} }
else else
{ {
baselen = (U_CHAR *) index (sym, '(') - sym; baselen = (U_CHAR *) strchr (sym, '(') - sym;
base = _cpp_lookup (pfile, sym, baselen); base = _cpp_lookup (pfile, sym, baselen);
if (! base) goto error; if (! base) goto error;
this = _cpp_lookup (pfile, sym, thislen); this = _cpp_lookup (pfile, sym, thislen);
...@@ -3153,7 +3153,7 @@ do_unassert (pfile, keyword) ...@@ -3153,7 +3153,7 @@ do_unassert (pfile, keyword)
void void
cpp_unassert (pfile, str) cpp_unassert (pfile, str)
cpp_reader *pfile; cpp_reader *pfile;
unsigned char *str; const char *str;
{ {
if (cpp_push_buffer (pfile, str, strlen (str)) != NULL) if (cpp_push_buffer (pfile, str, strlen (str)) != NULL)
{ {
......
...@@ -63,11 +63,11 @@ typedef int (*parse_cleanup_t) PARAMS((cpp_buffer *, cpp_reader *)); ...@@ -63,11 +63,11 @@ typedef int (*parse_cleanup_t) PARAMS((cpp_buffer *, cpp_reader *));
struct cpp_buffer struct cpp_buffer
{ {
unsigned char *cur; /* current position */ const unsigned char *cur; /* current position */
unsigned char *rlimit; /* end of valid data */ const unsigned char *rlimit; /* end of valid data */
unsigned char *buf; /* entire buffer */ const unsigned char *buf; /* entire buffer */
unsigned char *alimit; /* end of allocated buffer */ const unsigned char *alimit; /* end of allocated buffer */
unsigned char *line_base; /* start of current line */ const unsigned char *line_base; /* start of current line */
struct cpp_buffer *prev; struct cpp_buffer *prev;
...@@ -245,7 +245,7 @@ struct cpp_reader ...@@ -245,7 +245,7 @@ struct cpp_reader
/* Pointed to by cpp_reader.opts. */ /* Pointed to by cpp_reader.opts. */
struct cpp_options struct cpp_options
{ {
char *in_fname; const char *in_fname;
/* Name of output file, for error messages. */ /* Name of output file, for error messages. */
const char *out_fname; const char *out_fname;
...@@ -394,7 +394,7 @@ struct cpp_options ...@@ -394,7 +394,7 @@ struct cpp_options
/* Directory prefix that should replace `/usr/lib/gcc-lib/TARGET/VERSION' /* Directory prefix that should replace `/usr/lib/gcc-lib/TARGET/VERSION'
in the standard include file directories. */ in the standard include file directories. */
char *include_prefix; const char *include_prefix;
int include_prefix_len; int include_prefix_len;
char no_standard_includes; char no_standard_includes;
...@@ -427,7 +427,7 @@ struct cpp_options ...@@ -427,7 +427,7 @@ struct cpp_options
/* File name which deps are being written to. /* 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; const char *deps_file;
/* Target-name to write with the dependency information. */ /* Target-name to write with the dependency information. */
char *deps_target; char *deps_target;
...@@ -443,16 +443,16 @@ extern enum cpp_token get_directive_token PARAMS ((cpp_reader *)); ...@@ -443,16 +443,16 @@ extern enum cpp_token get_directive_token PARAMS ((cpp_reader *));
extern void cpp_reader_init PARAMS ((cpp_reader *)); extern void cpp_reader_init PARAMS ((cpp_reader *));
extern void cpp_options_init PARAMS ((cpp_options *)); extern void cpp_options_init PARAMS ((cpp_options *));
extern int cpp_start_read PARAMS ((cpp_reader *, char *)); extern int cpp_start_read PARAMS ((cpp_reader *, const char *));
extern void cpp_finish PARAMS ((cpp_reader *)); extern void cpp_finish PARAMS ((cpp_reader *));
extern void cpp_cleanup PARAMS ((cpp_reader *PFILE)); extern void cpp_cleanup PARAMS ((cpp_reader *PFILE));
extern void cpp_buf_line_and_col PARAMS((cpp_buffer *, long *, long *)); extern void cpp_buf_line_and_col PARAMS((cpp_buffer *, long *, long *));
extern cpp_buffer *cpp_file_buffer PARAMS((cpp_reader *)); extern cpp_buffer *cpp_file_buffer PARAMS((cpp_reader *));
extern void cpp_define PARAMS ((cpp_reader *, unsigned char *)); extern void cpp_define PARAMS ((cpp_reader *, const char *));
extern void cpp_assert PARAMS ((cpp_reader *, unsigned char *)); extern void cpp_assert PARAMS ((cpp_reader *, const char *));
extern void cpp_undef PARAMS ((cpp_reader *, unsigned char *)); extern void cpp_undef PARAMS ((cpp_reader *, const char *));
extern void cpp_unassert PARAMS ((cpp_reader *, unsigned char *)); extern void cpp_unassert PARAMS ((cpp_reader *, const char *));
/* N.B. The error-message-printer prototypes have not been nicely /* N.B. The error-message-printer prototypes have not been nicely
formatted because exgettext needs to see 'msgid' on the same line formatted because exgettext needs to see 'msgid' on the same line
...@@ -485,7 +485,7 @@ extern void cpp_notice_from_errno PARAMS ((cpp_reader *, const char *)); ...@@ -485,7 +485,7 @@ extern void cpp_notice_from_errno PARAMS ((cpp_reader *, const char *));
extern void cpp_grow_buffer PARAMS ((cpp_reader *, long)); extern void cpp_grow_buffer PARAMS ((cpp_reader *, long));
extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *, extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *,
unsigned char *, long)); const unsigned char *, long));
extern cpp_buffer *cpp_pop_buffer PARAMS ((cpp_reader *)); extern cpp_buffer *cpp_pop_buffer PARAMS ((cpp_reader *));
extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int)); extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int));
......
...@@ -173,7 +173,7 @@ deps_add_target (d, t) ...@@ -173,7 +173,7 @@ deps_add_target (d, t)
if (d->ntargets == d->targets_size) if (d->ntargets == d->targets_size)
{ {
d->targets_size *= 2; d->targets_size *= 2;
d->targetv = xrealloc (d->targetv, d->targetv = (const char **) xrealloc (d->targetv,
d->targets_size * sizeof (const char *)); d->targets_size * sizeof (const char *));
} }
...@@ -210,7 +210,8 @@ deps_add_dep (d, t) ...@@ -210,7 +210,8 @@ deps_add_dep (d, t)
if (d->ndeps == d->deps_size) if (d->ndeps == d->deps_size)
{ {
d->deps_size *= 2; d->deps_size *= 2;
d->depv = xrealloc (d->depv, d->deps_size * sizeof (const char *)); d->depv = (const char **)
xrealloc (d->depv, d->deps_size * sizeof (const char *));
} }
d->depv[d->ndeps++] = t; d->depv[d->ndeps++] = t;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment