summaryrefslogtreecommitdiff
path: root/lib-src/ebrowse.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-12-25 04:19:17 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2014-12-25 15:44:23 -0800
commit1e6879dbdb0832427f5c588c89a53a8a80768a00 (patch)
tree155493c6e140264c05356c667a1c9547a45e336f /lib-src/ebrowse.c
parent8dba53d239f5ac00e930f13b73f59cb5b53ffbd1 (diff)
downloademacs-1e6879dbdb0832427f5c588c89a53a8a80768a00.tar.gz
Prefer stpcpy to strcat
* admin/merge-gnulib (GNULIB_MODULES): Add stpcpy. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * lib/stpcpy.c, m4/stpcpy.m4: New files, from gnulib. * lib-src/ebrowse.c (sym_scope_1, operator_name, open_file): * lib-src/emacsclient.c (get_server_config, set_local_socket) (start_daemon_and_retry_set_socket): * lib-src/etags.c (main, C_entries, relative_filename): * lib-src/pop.c (sendline): * lib-src/update-game-score.c (main): * lwlib/xlwmenu.c (resource_widget_value): * src/callproc.c (child_setup): * src/dbusbind.c (xd_signature_cat): * src/doc.c (get_doc_string, Fsnarf_documentation): * src/editfns.c (Fuser_full_name): * src/frame.c (xrdb_get_resource): * src/gtkutil.c (xg_get_file_with_chooser): * src/tparam.c (tparam1): * src/xfns.c (xic_create_fontsetname): * src/xrdb.c (gethomedir, get_user_db, get_environ_db): * src/xsmfns.c (smc_save_yourself_CB): Rewrite to avoid the need for strcat, typically by using stpcpy and/or lispstpcpy. strcat tends to be part of O(N**2) algorithms. * src/doc.c (sibling_etc): * src/xrdb.c (xdefaults): Now a top-level static constant.
Diffstat (limited to 'lib-src/ebrowse.c')
-rw-r--r--lib-src/ebrowse.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index 29a88e85f02..b7431593c3e 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -1150,19 +1150,19 @@ sym_scope_1 (struct sym *p)
if (*scope_buffer)
{
ensure_scope_buffer_room (3);
- strcat (scope_buffer, "::");
+ strcpy (scope_buffer + scope_buffer_len, "::");
scope_buffer_len += 2;
}
len = strlen (p->name);
ensure_scope_buffer_room (len + 1);
- strcat (scope_buffer, p->name);
+ strcpy (scope_buffer + scope_buffer_len, p->name);
scope_buffer_len += len;
if (HAS_FLAG (p->flags, F_TEMPLATE))
{
ensure_scope_buffer_room (3);
- strcat (scope_buffer, "<>");
+ strcpy (scope_buffer + scope_buffer_len, "<>");
scope_buffer_len += 2;
}
@@ -2797,24 +2797,25 @@ operator_name (int *sc)
s = token_string (LA1);
MATCH ();
- len = strlen (s) + 10;
+ ptrdiff_t slen = strlen (s);
+ len = slen + 10;
if (len > id_size)
{
size_t new_size = max (len, 2 * id_size);
id = (char *) xrealloc (id, new_size);
id_size = new_size;
}
- strcpy (id, s);
+ char *z = stpcpy (id, s);
/* Vector new or delete? */
if (LOOKING_AT ('['))
{
- strcat (id, "[");
+ z = stpcpy (z, "[");
MATCH ();
if (LOOKING_AT (']'))
{
- strcat (id, "]");
+ strcpy (z, "]");
MATCH ();
}
}
@@ -2830,7 +2831,7 @@ operator_name (int *sc)
id = (char *) xrealloc (id, new_size);
id_size = new_size;
}
- strcpy (id, "operator");
+ char *z = stpcpy (id, "operator");
/* Beware access declarations of the form "X::f;" Beware of
`operator () ()'. Yet another difficulty is found in
@@ -2842,14 +2843,16 @@ operator_name (int *sc)
len += strlen (s) + 2;
if (len > id_size)
{
+ ptrdiff_t idlen = z - id;
size_t new_size = max (len, 2 * id_size);
id = (char *) xrealloc (id, new_size);
id_size = new_size;
+ z = id + idlen;
}
if (*s != ')' && *s != ']')
- strcat (id, " ");
- strcat (id, s);
+ *z++ = ' ';
+ z = stpcpy (z, s);
MATCH ();
/* If this is a simple operator like `+', stop now. */
@@ -3462,9 +3465,9 @@ open_file (char *file)
buffer = (char *) xrealloc (buffer, buffer_size);
}
- strcpy (buffer, path->path);
- strcat (buffer, "/");
- strcat (buffer, file);
+ char *z = stpcpy (buffer, path->path);
+ *z++ = '/';
+ strcpy (z, file);
fp = fopen (buffer, "r");
}