cpplib: more type correctness

Neil Booth NeilB@earthling.net
Thu Mar 9 03:47:00 GMT 2000


This patch:

o Replaces all remaining b- and (r)index function calls
o Adds casts to the return value of all memory allocations
o Makes some char pointers "pointers to const" which previously were
not

The last point will be handy if we move towards mmap-ping input files
read only.  One effect of the patch is that the number of signedness
warnings emitted when compiling -traditional is well down; almost all
now lie in cpplib.c and cppexp.c.  With this cpplib is -Wwrite-strings
clean.

gcc bootstraps with the patch applied.

OK to commit?

Neil.

	* cppfiles.c (file_cleanup, _cpp_find_include_file,
	read_filename_string, read_name_map, remap_filename,
	_cpp_read_include_file, actual_directory,
	hack_vms_include_specification): Replace bcopy(), index() etc
	calls.  Add casts to 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, cpp_undefine, cpp_assert, do_include,
	do_define, 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, cpp_unassert): Similarly.
	* cpplib.h (cpp_buffer, cpp_options): Update types.  Update
	function prototypes.
	* mkdeps.c (munge, deps_add_target, deps_add_dep): cast
	allocations.	

Index: cppfiles.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cppfiles.c,v
retrieving revision 1.43
diff -u -p -r1.43 cppfiles.c
--- cppfiles.c	2000/03/08 23:35:18	1.43
+++ cppfiles.c	2000/03/09 11:38:03
@@ -165,7 +165,7 @@ file_cleanup (pbuf, pfile)
 {
   if (pbuf->buf)
     {
-      free (pbuf->buf);
+      free ((U_CHAR *) pbuf->buf);
       pbuf->buf = 0;
     }
   if (pfile->system_include_depth)
@@ -242,11 +242,12 @@ _cpp_find_include_file (pfile, fname, se
   /* Search directory path, trying to open the file. */
 
   len = strlen (fname);
-  name = xmalloc (len + pfile->max_include_len + 2 + INCLUDE_LEN_FUDGE);
+  name = (char *)
+    xmalloc (len + pfile->max_include_len + 2 + INCLUDE_LEN_FUDGE);
 
   for (l = search_start; l; l = l->next)
     {
-      bcopy (l->name, name, l->nlen);
+      memcpy (name, l->name, l->nlen);
       name[l->nlen] = '/';
       strcpy (&name[l->nlen+1], fname);
       _cpp_simplify_pathname (name);
@@ -266,7 +267,7 @@ _cpp_find_include_file (pfile, fname, se
       if (f >= 0)
         {
 	  ih->foundhere = l;
-	  ih->name = xrealloc (name, strlen (name)+1);
+	  ih->name = (const char *) xrealloc (name, strlen (name)+1);
 	  return f;
         }
     }
@@ -310,7 +311,7 @@ read_filename_string (ch, f)
   int len;
 
   len = 20;
-  set = alloc = xmalloc (len + 1);
+  set = alloc = (char *) xmalloc (len + 1);
   if (! is_space(ch))
     {
       *set++ = ch;
@@ -319,7 +320,7 @@ read_filename_string (ch, f)
 	  if (set - alloc == len)
 	    {
 	      len *= 2;
-	      alloc = xrealloc (alloc, len + 1);
+	      alloc = (char *) xrealloc (alloc, len + 1);
 	      set = alloc + len / 2;
 	    }
 	  *set++ = ch;
@@ -393,7 +394,7 @@ read_name_map (pfile, dirname)
 	    ptr->map_to = to;
 	  else
 	    {
-	      ptr->map_to = xmalloc (dirlen + strlen (to) + 2);
+	      ptr->map_to = (char *) xmalloc (dirlen + strlen (to) + 2);
 	      strcpy (ptr->map_to, dirname);
 	      ptr->map_to[dirlen] = '/';
 	      strcpy (ptr->map_to + dirlen + 1, to);
@@ -445,7 +446,7 @@ remap_filename (pfile, name, loc)
      looking in.  Thus #include <sys/types.h> will look up sys/types.h
      in /usr/include/header.gcc and look up types.h in
      /usr/include/sys/header.gcc.  */
-  p = rindex (name, '/');
+  p = strrchr (name, '/');
   if (!p)
     p = name;
   if (loc && loc->name
@@ -462,7 +463,7 @@ remap_filename (pfile, name, loc)
   else
     {
       char * newdir = (char *) alloca (p - name + 1);
-      bcopy (name, newdir, p - name);
+      memcpy (newdir, name, p - name);
       newdir[p - name] = '\0';
       dir = newdir;
       from = p + 1;
@@ -614,7 +615,7 @@ _cpp_read_include_file (pfile, fd, ihash
   if (length < 0)
     goto fail;
   if (length == 0)
-    ihash->control_macro = "";  /* never re-include */
+    ihash->control_macro = (U_CHAR *) "";  /* never re-include */
 
   close (fd);
   fp->rlimit = fp->alimit = fp->buf + length;
@@ -657,7 +658,7 @@ actual_directory (pfile, fname)
   struct file_name_list *x;
   
   dir = xstrdup (fname);
-  last_slash = rindex (dir, '/');
+  last_slash = strrchr (dir, '/');
   if (last_slash)
     {
       if (last_slash == dir)
@@ -1266,20 +1267,20 @@ hack_vms_include_specification (fullname
   check_filename_before_returning = 0;
   must_revert = 0;
   /* 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)
     return 0;				/* Nothing to do!!! */
 
   /* 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 (first_slash == fullname)
 	{
-	  first_slash = index (fullname+1, '/');	/* 2nd slash ? */
+	  first_slash = strchr (fullname+1, '/');	/* 2nd slash ? */
 	  if (first_slash)
 	    *first_slash = ':';				/* make device spec  */
 	  for (basename = fullname; *basename != 0; basename++)
@@ -1399,7 +1400,7 @@ hack_vms_include_specification (fullname
      in the "root" directory.  Otherwise, we need to add
      directory specifications.  */
 
-  if (index (unixname, '/') == 0)
+  if (strchr (unixname, '/') == 0)
     {
       /* if no directories specified yet and none are following.  */
       if (local_ptr[-1] == '[')
@@ -1414,7 +1415,7 @@ hack_vms_include_specification (fullname
     {
 
       /* 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 it's not at the beginning of a path.  */
@@ -1496,8 +1497,8 @@ hack_vms_include_specification (fullname
       /* The filename did not work.  Try to remove the [000000] from the name,
 	 and return it.  */
 
-      basename = index (fullname, '[');
-      local_ptr = index (fullname, ']') + 1;
+      basename = strchr (fullname, '[');
+      local_ptr = strchr (fullname, ']') + 1;
       strcpy (basename, local_ptr);		/* this gets rid of it */
 
     }
Index: cpphash.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpphash.c,v
retrieving revision 1.50
diff -u -p -r1.50 cpphash.c
--- cpphash.c	2000/03/08 20:37:23	1.50
+++ cpphash.c	2000/03/09 11:38:05
@@ -237,7 +237,7 @@ _cpp_install (pfile, name, len, type, va
   hp->length = len;
   hp->value.cpval = value;
   hp->name = ((U_CHAR *) hp) + sizeof (HASHNODE);
-  bcopy (name, hp->name, len);
+  memcpy (hp->name, name, len);
   hp->name[len] = 0;
   return hp;
 }
@@ -251,7 +251,7 @@ macro_cleanup (pbuf, pfile)
   if (macro->type == T_DISABLED)
     macro->type = T_MACRO;
   if (macro->type != T_MACRO || pbuf->buf != macro->value.defn->expansion)
-    free (pbuf->buf);
+    free ((U_CHAR *) pbuf->buf);
   return 0;
 }
 
@@ -493,7 +493,7 @@ collect_expansion (pfile, arglist)
   if (last_token == START)
     {
       /* Empty macro definition.  */
-      exp = xstrdup ("\r \r ");
+      exp = (U_CHAR *) xstrdup ("\r \r ");
       len = 1;
     }
   else
@@ -506,7 +506,8 @@ collect_expansion (pfile, arglist)
   
       CPP_NUL_TERMINATE (pfile);
       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[1] = ' ';
       exp[len + 1] = '\r';
@@ -580,7 +581,7 @@ collect_formal_parameters (pfile)
 	  tok = pfile->token_buffer + old_written;
 	  len = CPP_PWRITTEN (pfile) - tok;
 	  if (namebuf
-	      && (name = strstr (namebuf, tok))
+	      && (name = (U_CHAR *) strstr (namebuf, tok))
 	      && name[len] == ','
 	      && (name == namebuf || name[-1] == ','))
 	    {
@@ -591,7 +592,7 @@ collect_formal_parameters (pfile)
 	      && strncmp (tok, "__VA_ARGS__", sizeof "__VA_ARGS__" - 1))
 	    cpp_pedwarn (pfile,
 	"C99 does not permit use of `__VA_ARGS__' as a macro argument name");
-	  namebuf = xrealloc (namebuf, argslen + len + 1);
+	  namebuf = (U_CHAR *) xrealloc (namebuf, argslen + len + 1);
 	  name = &namebuf[argslen - 1];
 	  argslen += len + 1;
 
@@ -604,7 +605,7 @@ collect_formal_parameters (pfile)
 
 	case CPP_COMMA:
 	  argc++;
-	  argv = xrealloc (argv, (argc + 1)*sizeof(struct arg));
+	  argv = (struct arg *) xrealloc (argv, (argc + 1)*sizeof(struct arg));
 	  argv[argc].len = 0;
 	  break;
 
@@ -637,7 +638,7 @@ collect_formal_parameters (pfile)
 	cpp_pedwarn (pfile, "C89 does not permit varargs macros");
 
       len = sizeof "__VA_ARGS__" - 1;
-      namebuf = xrealloc (namebuf, argslen + len + 1);
+      namebuf = (U_CHAR *) xrealloc (namebuf, argslen + len + 1);
       name = &namebuf[argslen - 1];
       argslen += len;
       memcpy (name, "__VA_ARGS__", len);
Index: cppinit.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cppinit.c,v
retrieving revision 1.56
diff -u -p -r1.56 cppinit.c
--- cppinit.c	2000/03/08 23:35:18	1.56
+++ cppinit.c	2000/03/09 11:38:07
@@ -167,7 +167,7 @@ static const struct default_include incl
 struct pending_option
 {
   struct pending_option *next;
-  char *arg;
+  const char *arg;
   int undef;
 };
 
@@ -354,7 +354,7 @@ append_include_chain (pfile, pend, dir, 
   if (len > pfile->max_include_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->nlen = len;
   new->ino  = st.st_ino;
@@ -530,7 +530,7 @@ void
 cpp_options_init (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->cplusplus_comments = 1;
@@ -546,7 +546,7 @@ void
 cpp_reader_init (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 = (U_CHAR *) xmalloc (pfile->token_buffer_size);
@@ -747,7 +747,7 @@ initialize_standard_includes (pfile)
   cpp_options *opts = CPP_OPTIONS (pfile);
   char *path;
   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.
      CPATH specifies an additional list of directories to be searched
@@ -781,7 +781,7 @@ initialize_standard_includes (pfile)
      These have /usr/local/lib/gcc... replaced by specd_prefix.  */
   if (specd_prefix != 0)
     {
-      char *default_prefix = alloca (sizeof GCC_INCLUDE_DIR - 7);
+      char *default_prefix = (char *) alloca (sizeof GCC_INCLUDE_DIR - 7);
       /* Remove the `include' from /usr/local/lib/gcc.../include.
 	 GCC_INCLUDE_DIR will always end in /include. */
       int default_len = sizeof GCC_INCLUDE_DIR - 8;
@@ -841,7 +841,7 @@ initialize_standard_includes (pfile)
 int
 cpp_start_read (pfile, fname)
      cpp_reader *pfile;
-     char *fname;
+     const char *fname;
 {
   struct cpp_options *opts = CPP_OPTIONS (pfile);
   struct pending_option *p, *q;
@@ -1054,7 +1054,7 @@ new_pending_define (opts, text)
   struct pending_option *o = (struct pending_option *)
     xmalloc (sizeof (struct pending_option));
 
-  o->arg = (char *) text;
+  o->arg = text;
   o->next = NULL;
   o->undef = 0;
   APPEND (opts->pending, define, o);
@@ -1268,7 +1268,7 @@ handle_option (pfile, argc, argv)
     {
       enum opt_code opt_code;
       int opt_index;
-      char *arg = 0;
+      const char *arg = 0;
 
       /* Skip over '-' */
       opt_index = parse_option (&argv[i][1]);
@@ -1640,13 +1640,13 @@ handle_option (pfile, argc, argv)
  
 	    if (opts->include_prefix != 0)
 	      {
-		fname = xmalloc (opts->include_prefix_len + len + 1);
+		fname = (char *) xmalloc (opts->include_prefix_len + len + 1);
 		memcpy (fname, opts->include_prefix, opts->include_prefix_len);
 		memcpy (fname + opts->include_prefix_len, arg, len + 1);
 	      }
 	    else
 	      {
-		fname = xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len);
+		fname = (char *) xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len);
 		memcpy (fname, GCC_INCLUDE_DIR, sizeof GCC_INCLUDE_DIR - 9);
 		memcpy (fname + sizeof GCC_INCLUDE_DIR - 9, arg, len + 1);
 	      }
Index: cpplib.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplib.c,v
retrieving revision 1.129
diff -u -p -r1.129 cpplib.c
--- cpplib.c	2000/03/08 23:35:18	1.129
+++ cpplib.c	2000/03/09 11:38:10
@@ -214,9 +214,9 @@ cpp_grow_buffer (pfile, n)
 void
 cpp_define (pfile, str)
      cpp_reader *pfile;
-     U_CHAR *str;
+     const char *str;
 {
-  U_CHAR *buf, *p;
+  char *buf, *p;
   size_t count;
 
   p = strchr (str, '=');
@@ -227,7 +227,7 @@ cpp_define (pfile, str)
   if (p)
     {
       count = strlen (str) + 2;
-      buf = (U_CHAR *) alloca (count);
+      buf = (char *) alloca (count);
       memcpy (buf, str, count - 2);
       buf[p - str] = ' ';
       buf[count - 2] = '\n';
@@ -236,7 +236,7 @@ cpp_define (pfile, str)
   else
     {
       count = strlen (str) + 4;
-      buf = (U_CHAR *) alloca (count);
+      buf = (char *) alloca (count);
       memcpy (buf, str, count - 4);
       strcpy (&buf[count-4], " 1\n");
     }
@@ -252,7 +252,7 @@ cpp_define (pfile, str)
 void
 cpp_assert (pfile, str)
      cpp_reader *pfile;
-     U_CHAR *str;
+     const char *str;
 {
   if (cpp_push_buffer (pfile, str, strlen (str)) != NULL)
     {
@@ -409,8 +409,8 @@ copy_comment (pfile, m)
      cpp_reader *pfile;
      int m;
 {
-  U_CHAR *start = CPP_BUFFER (pfile)->cur;  /* XXX Layering violation */
-  U_CHAR *limit;
+  const U_CHAR *start = CPP_BUFFER (pfile)->cur;  /* XXX Layering violation */
+  const U_CHAR *limit;
 
   if (skip_comment (pfile, m) == m)
     return m;
@@ -749,7 +749,7 @@ do_define (pfile, keyword)
 cpp_buffer *
 cpp_push_buffer (pfile, buffer, length)
      cpp_reader *pfile;
-     U_CHAR *buffer;
+     const U_CHAR *buffer;
      long length;
 {
   cpp_buffer *buf = CPP_BUFFER (pfile);
@@ -1258,7 +1258,7 @@ do_include (pfile, keyword)
   /* Actually process the file */
 
   if (importing)
-    ihash->control_macro = "";
+    ihash->control_macro = (U_CHAR *) "";
   
   if (cpp_push_buffer (pfile, NULL, 0) == NULL)
     {
@@ -1491,11 +1491,11 @@ do_undef (pfile, keyword)
 void
 cpp_undef (pfile, macro)
      cpp_reader *pfile;
-     U_CHAR *macro;
+     const char *macro;
 {
   /* Copy the string so we can append a newline.  */
   size_t len = strlen (macro);
-  U_CHAR *buf = alloca (len + 2);
+  char *buf = (char *) alloca (len + 2);
   memcpy (buf, macro, len);
   buf[len]     = '\n';
   buf[len + 1] = '\0';
@@ -1517,7 +1517,7 @@ do_error (pfile, keyword)
      cpp_reader *pfile;
      const struct directive *keyword ATTRIBUTE_UNUSED;
 {
-  U_CHAR *text, *limit;
+  const U_CHAR *text, *limit;
 
   cpp_skip_hspace (pfile);
   text = CPP_BUFFER (pfile)->cur;
@@ -1538,7 +1538,7 @@ do_warning (pfile, keyword)
      cpp_reader *pfile;
      const struct directive *keyword ATTRIBUTE_UNUSED;
 {
-  U_CHAR *text, *limit;
+  const U_CHAR *text, *limit;
 
   cpp_skip_hspace (pfile);
   text = CPP_BUFFER (pfile)->cur;
@@ -1626,7 +1626,7 @@ do_pragma (pfile, keyword)
   buf = pfile->token_buffer + key;
   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"))
     pop = do_pragma_once (pfile);
   else if (tokis ("implementation"))
@@ -1677,7 +1677,7 @@ do_pragma_once (pfile)
   if (CPP_PREV_BUFFER (ip) == NULL)
     cpp_warning (pfile, "`#pragma once' outside include file");
   else
-    ip->ihash->control_macro = "";  /* never repeat */
+    ip->ihash->control_macro = (U_CHAR *) "";  /* never repeat */
 
   return 1;
 }
@@ -1703,7 +1703,7 @@ do_pragma_implementation (pfile)
     }
 
   name = pfile->token_buffer + written + 1;
-  copy = xstrdup (name);
+  copy = (U_CHAR *) xstrdup (name);
   copy[strlen(copy)] = '\0';  /* trim trailing quote */
 
   if (cpp_included (pfile, copy))
@@ -1844,7 +1844,7 @@ detect_if_not_defined (pfile)
       if ((!need_rparen || get_directive_token (pfile) == CPP_RPAREN)
 	  /* ...and make sure there's nothing else on the line.  */
 	  && get_directive_token (pfile) == CPP_VSPACE)
-	control_macro = xstrdup (ident);
+	control_macro = (U_CHAR *) xstrdup (ident);
 
     restore:
       CPP_SET_WRITTEN (pfile, base_offset);
@@ -1980,7 +1980,7 @@ do_ifdef (pfile, keyword)
       if (start_of_file && !skip)
 	{
 	  control_macro = (U_CHAR *) xmalloc (ident_length + 1);
-	  bcopy (ident, control_macro, ident_length + 1);
+	  memcpy (control_macro, ident, ident_length + 1);
 	}
     }
   else
@@ -2114,7 +2114,7 @@ skip_if_group (pfile)
 {
   int c;
   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;
 
   old_written = CPP_WRITTEN (pfile);
@@ -2674,7 +2674,7 @@ cpp_get_token (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 (;;)
 		    {
 		      cpp_skip_hspace (pfile);
@@ -2929,8 +2929,8 @@ parse_string (pfile, c)
      cpp_reader *pfile;
      int c;
 {
-  U_CHAR *start = CPP_BUFFER (pfile)->cur;  /* XXX Layering violation */
-  U_CHAR *limit;
+  const U_CHAR *start = CPP_BUFFER (pfile)->cur;  /* XXX Layering violation */
+  const U_CHAR *limit;
 
   skip_string (pfile, c);
 
@@ -3050,7 +3050,7 @@ do_assert (pfile, keyword)
     }
 
   thislen = strlen (sym);
-  baselen = (U_CHAR *) index (sym, '(') - sym;
+  baselen = (U_CHAR *) strchr (sym, '(') - sym;
   this = _cpp_lookup (pfile, sym, thislen);
   if (this)
     {
@@ -3124,7 +3124,7 @@ do_unassert (pfile, keyword)
     }
   else
     {
-      baselen = (U_CHAR *) index (sym, '(') - sym;
+      baselen = (U_CHAR *) strchr (sym, '(') - sym;
       base = _cpp_lookup (pfile, sym, baselen);
       if (! base) goto error;
       this = _cpp_lookup (pfile, sym, thislen);
@@ -3153,7 +3153,7 @@ do_unassert (pfile, keyword)
 void
 cpp_unassert (pfile, str)
      cpp_reader *pfile;
-     unsigned char *str;
+     const char *str;
 {
   if (cpp_push_buffer (pfile, str, strlen (str)) != NULL)
     {
Index: cpplib.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplib.h,v
retrieving revision 1.68
diff -u -p -r1.68 cpplib.h
--- cpplib.h	2000/03/08 23:35:19	1.68
+++ cpplib.h	2000/03/09 11:38:11
@@ -63,11 +63,11 @@ typedef int (*parse_cleanup_t) PARAMS((c
 
 struct cpp_buffer
 {
-  unsigned char *cur;	 /* current position */
-  unsigned char *rlimit; /* end of valid data */
-  unsigned char *buf;	 /* entire buffer */
-  unsigned char *alimit; /* end of allocated buffer */
-  unsigned char *line_base; /* start of current line */
+  const unsigned char *cur;	 /* current position */
+  const unsigned char *rlimit; /* end of valid data */
+  const unsigned char *buf;	 /* entire buffer */
+  const unsigned char *alimit; /* end of allocated buffer */
+  const unsigned char *line_base; /* start of current line */
 
   struct cpp_buffer *prev;
 
@@ -245,7 +245,7 @@ struct cpp_reader
 /* Pointed to by cpp_reader.opts. */
 struct cpp_options
 {
-  char *in_fname;
+  const char *in_fname;
 
   /* Name of output file, for error messages.  */
   const char *out_fname;
@@ -394,7 +394,7 @@ struct cpp_options
 
   /* Directory prefix that should replace `/usr/lib/gcc-lib/TARGET/VERSION'
      in the standard include file directories.  */
-  char *include_prefix;
+  const char *include_prefix;
   int include_prefix_len;
 
   char no_standard_includes;
@@ -427,7 +427,7 @@ struct cpp_options
 
   /* File name which deps are being written to.
      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.  */
   char *deps_target;
@@ -443,16 +443,16 @@ extern enum cpp_token get_directive_toke
 
 extern void cpp_reader_init PARAMS ((cpp_reader *));
 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_cleanup PARAMS ((cpp_reader *PFILE));
 
 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_assert PARAMS ((cpp_reader *, unsigned char *));
-extern void cpp_undef  PARAMS ((cpp_reader *, unsigned char *));
-extern void cpp_unassert PARAMS ((cpp_reader *, unsigned char *));
+extern void cpp_define PARAMS ((cpp_reader *, const char *));
+extern void cpp_assert PARAMS ((cpp_reader *, const char *));
+extern void cpp_undef  PARAMS ((cpp_reader *, const char *));
+extern void cpp_unassert PARAMS ((cpp_reader *, const char *));
 
 /* N.B. The error-message-printer prototypes have not been nicely
    formatted because exgettext needs to see 'msgid' on the same line
@@ -485,7 +485,7 @@ extern void cpp_notice_from_errno PARAMS
 
 extern void cpp_grow_buffer PARAMS ((cpp_reader *, long));
 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 int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int));
 
Index: mkdeps.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/mkdeps.c,v
retrieving revision 1.5
diff -u -p -r1.5 mkdeps.c
--- mkdeps.c	2000/03/07 23:11:06	1.5
+++ mkdeps.c	2000/03/09 11:38:11
@@ -72,7 +72,7 @@ munge (filename)
     }
 
   /* Now we know how big to make the buffer.  */
-  buffer = malloc (len + 1);
+  buffer = (char *) malloc (len + 1);
 
   for (p = filename, dst = buffer; *p; p++, dst++)
     {
@@ -173,7 +173,7 @@ deps_add_target (d, t)
   if (d->ntargets == d->targets_size)
     {
       d->targets_size *= 2;
-      d->targetv = xrealloc (d->targetv,
+      d->targetv = (const char **) xrealloc (d->targetv,
 			     d->targets_size * sizeof (const char *));
     }
 
@@ -210,7 +210,8 @@ deps_add_dep (d, t)
   if (d->ndeps == d->deps_size)
     {
       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;
 }



More information about the Gcc-patches mailing list