This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
removal of savestring() from cpplib
- To: brolley at cygnus dot com, egcs-patches at cygnus dot com
- Subject: removal of savestring() from cpplib
- From: Zack Weinberg <zack at rabi dot columbia dot edu>
- Date: Mon, 14 Dec 1998 16:25:44 -0500
It's now possible to replace savestring by xstrdup without breaking
anything.
zw
1998-12-14 16:22 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cppalloc.c: Add xstrdup here.
* cpplib.h: Remove savestring prototype.
* cpplib.c: Remove savestring function. s/savestring/xstrdup/
throughout.
* cppfiles.c: s/savestring/xstrdup/ throughout.
--- cppalloc.c.ss Mon Dec 14 13:19:18 1998
+++ cppalloc.c Mon Dec 14 13:31:57 1998
@@ -65,3 +65,13 @@
memory_full ();
return ptr;
}
+
+char *
+xstrdup (input)
+ const char *input;
+{
+ unsigned size = strlen (input);
+ char *output = xmalloc (size + 1);
+ strcpy (output, input);
+ return output;
+}
--- cppfiles.c.ss Mon Dec 14 13:16:50 1998
+++ cppfiles.c Mon Dec 14 13:18:29 1998
@@ -74,7 +74,7 @@
struct stat st;
unsigned int len;
- dir = savestring (dir);
+ dir = xstrdup (dir);
simplify_pathname (dir);
if (stat (dir, &st))
{
@@ -410,7 +410,7 @@
}
*before = 0;
*ihash = ih;
- ih->nshort = savestring (fname);
+ ih->nshort = xstrdup (fname);
ih->control_macro = NULL;
/* If the pathname is absolute, just open it. */
@@ -539,7 +539,7 @@
map_list_ptr = ((struct file_name_map_list *)
xmalloc (sizeof (struct file_name_map_list)));
- map_list_ptr->map_list_name = savestring (dirname);
+ map_list_ptr->map_list_name = xstrdup (dirname);
name = (char *) alloca (strlen (dirname) + strlen (FILE_NAME_MAP_FILE) + 2);
strcpy (name, dirname);
@@ -772,7 +772,7 @@
size_t dlen;
struct file_name_list *x;
- dir = savestring (fname);
+ dir = xstrdup (fname);
last_slash = rindex (dir, '/');
if (last_slash)
{
--- cpplib.c.ss Mon Dec 14 13:16:34 1998
+++ cpplib.c Mon Dec 14 13:17:44 1998
@@ -4892,7 +4892,7 @@
else
nstore[endp-startp] = '\0';
- include_defaults[num_dirs].fname = savestring (nstore);
+ include_defaults[num_dirs].fname = xstrdup (nstore);
include_defaults[num_dirs].component = 0;
include_defaults[num_dirs].cplusplus = opts->cplusplus;
include_defaults[num_dirs].cxx_aware = 1;
@@ -4915,7 +4915,7 @@
if (!opts->no_standard_includes) {
struct default_include *p = include_defaults;
char *specd_prefix = opts->include_prefix;
- char *default_prefix = savestring (GCC_INCLUDE_DIR);
+ char *default_prefix = xstrdup (GCC_INCLUDE_DIR);
int default_len = 0;
/* Remove the `include' from /usr/local/lib/gcc.../include. */
if (!strcmp (default_prefix + strlen (default_prefix) - 8, "/include")) {
@@ -6164,20 +6164,6 @@
return result;
}
-/* FIXME: savestring() should be renamed strdup() and should
- be moved into cppalloc.c. We can't do that right now because
- then we'd get multiple-symbol clashes with toplev.c and several
- other people. */
-char *
-savestring (input)
- char *input;
-{
- unsigned size = strlen (input);
- char *output = xmalloc (size + 1);
- strcpy (output, input);
- return output;
-}
-
/* Initialize PMARK to remember the current position of PFILE. */
void
--- cpplib.h.ss Mon Dec 14 13:16:39 1998
+++ cpplib.h Mon Dec 14 13:18:00 1998
@@ -725,8 +725,6 @@
extern void deps_output PROTO ((cpp_reader *, char *, int));
extern struct include_hash *include_hash PROTO ((cpp_reader *, char *, int));
-/* Bleargh. */
-extern char *savestring PROTO ((char *));
#ifndef INCLUDE_LEN_FUDGE
#define INCLUDE_LEN_FUDGE 0
#endif