summaryrefslogtreecommitdiff
path: root/m4
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 /m4
parent8dba53d239f5ac00e930f13b73f59cb5b53ffbd1 (diff)
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 'm4')
-rw-r--r--m4/gnulib-comp.m49
-rw-r--r--m4/stpcpy.m425
2 files changed, 34 insertions, 0 deletions
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 39ec8ae00e..49fdf5ef19 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -123,6 +123,7 @@ AC_DEFUN([gl_EARLY],
# Code from module stdint:
# Code from module stdio:
# Code from module stdlib:
+ # Code from module stpcpy:
# Code from module strftime:
# Code from module string:
# Code from module strtoimax:
@@ -341,6 +342,12 @@ AC_DEFUN([gl_INIT],
gl_STDINT_H
gl_STDIO_H
gl_STDLIB_H
+ gl_FUNC_STPCPY
+ if test $HAVE_STPCPY = 0; then
+ AC_LIBOBJ([stpcpy])
+ gl_PREREQ_STPCPY
+ fi
+ gl_STRING_MODULE_INDICATOR([stpcpy])
gl_FUNC_GNU_STRFTIME
gl_HEADER_STRING_H
gl_FUNC_STRTOIMAX
@@ -889,6 +896,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/stdint.in.h
lib/stdio.in.h
lib/stdlib.in.h
+ lib/stpcpy.c
lib/strftime.c
lib/strftime.h
lib/string.in.h
@@ -995,6 +1003,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/stdint.m4
m4/stdio_h.m4
m4/stdlib_h.m4
+ m4/stpcpy.m4
m4/strftime.m4
m4/string_h.m4
m4/strtoimax.m4
diff --git a/m4/stpcpy.m4 b/m4/stpcpy.m4
new file mode 100644
index 0000000000..966ba951f5
--- /dev/null
+++ b/m4/stpcpy.m4
@@ -0,0 +1,25 @@
+# stpcpy.m4 serial 8
+dnl Copyright (C) 2002, 2007, 2009-2014 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_STPCPY],
+[
+ dnl Persuade glibc <string.h> to declare stpcpy().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ dnl The stpcpy() declaration in lib/string.in.h uses 'restrict'.
+ AC_REQUIRE([AC_C_RESTRICT])
+
+ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_CHECK_FUNCS([stpcpy])
+ if test $ac_cv_func_stpcpy = no; then
+ HAVE_STPCPY=0
+ fi
+])
+
+# Prerequisites of lib/stpcpy.c.
+AC_DEFUN([gl_PREREQ_STPCPY], [
+ :
+])