aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2014-12-25 04:19:17 -0800
committerPaul Eggert2014-12-25 15:44:23 -0800
commit1e6879dbdb0832427f5c588c89a53a8a80768a00 (patch)
tree155493c6e140264c05356c667a1c9547a45e336f /lib
parent8dba53d239f5ac00e930f13b73f59cb5b53ffbd1 (diff)
downloademacs-1e6879dbdb0832427f5c588c89a53a8a80768a00.tar.gz
emacs-1e6879dbdb0832427f5c588c89a53a8a80768a00.zip
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')
-rw-r--r--lib/gnulib.mk11
-rw-r--r--lib/stpcpy.c49
2 files changed, 59 insertions, 1 deletions
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 740ebb1e96c..27a5964cd7c 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -21,7 +21,7 @@
21# the same distribution terms as the rest of that program. 21# the same distribution terms as the rest of that program.
22# 22#
23# Generated by gnulib-tool. 23# Generated by gnulib-tool.
24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stddef stdio strftime strtoimax strtoumax symlink sys_stat sys_time time time_r timer-time timespec-add timespec-sub unsetenv update-copyright utimens vla warnings 24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stddef stdio stpcpy strftime strtoimax strtoumax symlink sys_stat sys_time time time_r timer-time timespec-add timespec-sub unsetenv update-copyright utimens vla warnings
25 25
26 26
27MOSTLYCLEANFILES += core *.stackdump 27MOSTLYCLEANFILES += core *.stackdump
@@ -1214,6 +1214,15 @@ EXTRA_DIST += stdlib.in.h
1214 1214
1215## end gnulib module stdlib 1215## end gnulib module stdlib
1216 1216
1217## begin gnulib module stpcpy
1218
1219
1220EXTRA_DIST += stpcpy.c
1221
1222EXTRA_libgnu_a_SOURCES += stpcpy.c
1223
1224## end gnulib module stpcpy
1225
1217## begin gnulib module strftime 1226## begin gnulib module strftime
1218 1227
1219libgnu_a_SOURCES += strftime.c 1228libgnu_a_SOURCES += strftime.c
diff --git a/lib/stpcpy.c b/lib/stpcpy.c
new file mode 100644
index 00000000000..880a7061ef1
--- /dev/null
+++ b/lib/stpcpy.c
@@ -0,0 +1,49 @@
1/* stpcpy.c -- copy a string and return pointer to end of new string
2 Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2014 Free Software
3 Foundation, Inc.
4
5 NOTE: The canonical source of this file is maintained with the GNU C Library.
6 Bugs can be reported to bug-glibc@prep.ai.mit.edu.
7
8 This program is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or any
11 later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21#include <config.h>
22
23#include <string.h>
24
25#undef __stpcpy
26#ifdef _LIBC
27# undef stpcpy
28#endif
29
30#ifndef weak_alias
31# define __stpcpy stpcpy
32#endif
33
34/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
35char *
36__stpcpy (char *dest, const char *src)
37{
38 register char *d = dest;
39 register const char *s = src;
40
41 do
42 *d++ = *s;
43 while (*s++ != '\0');
44
45 return d - 1;
46}
47#ifdef weak_alias
48weak_alias (__stpcpy, stpcpy)
49#endif