summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-09-23 10:03:48 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2014-09-23 10:03:48 -0700
commit97914756e8de76b8e83550eab2e12e5dfcb87754 (patch)
tree81c4f9d262e1cce19a6294658231bf854a4d8029
parentccc7be94d73afce4295b6ee7eaa388d1cd930926 (diff)
* lisp.h (lispstpcpy): Rename from lispstrcpy, and act like stpcpy.
All callers changed. * xterm.c (x_term_init): Use new functionality to avoid two needs to compute a string length.
-rw-r--r--src/ChangeLog5
-rw-r--r--src/callproc.c2
-rw-r--r--src/dbusbind.c2
-rw-r--r--src/doc.c2
-rw-r--r--src/font.c2
-rw-r--r--src/frame.c4
-rw-r--r--src/lisp.h9
-rw-r--r--src/process.c4
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32proc.c2
-rw-r--r--src/xfns.c2
-rw-r--r--src/xfont.c2
-rw-r--r--src/xsmfns.c2
-rw-r--r--src/xterm.c5
14 files changed, 27 insertions, 18 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7e1768e2cd..7f05f6fe21 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
2014-09-23 Paul Eggert <eggert@cs.ucla.edu>
+ * lisp.h (lispstpcpy): Rename from lispstrcpy, and act like stpcpy.
+ All callers changed.
+ * xterm.c (x_term_init): Use new functionality to avoid two needs
+ to compute a string length.
+
* dispextern.h, xdisp.c (window_box_right_offset): Now static.
2014-09-23 Dmitry Antipov <dmantipov@yandex.ru>
diff --git a/src/callproc.c b/src/callproc.c
index 2fa475e72d..e3dcc7bbcc 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1235,7 +1235,7 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
#endif
temp = pwd_var + 4;
memcpy (pwd_var, "PWD=", 4);
- lispstrcpy (temp, current_dir);
+ lispstpcpy (temp, current_dir);
#ifndef DOS_NT
/* We can't signal an Elisp error here; we're in a vfork. Since
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 58302df492..f81666ba7b 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -761,7 +761,7 @@ xd_append_arg (int dtype, Lisp_Object object, DBusMessageIter *iter)
&& STRINGP (CAR_SAFE (XD_NEXT_VALUE (object)))
&& NILP (CDR_SAFE (XD_NEXT_VALUE (object))))
{
- lispstrcpy (signature, CAR_SAFE (XD_NEXT_VALUE (object)));
+ lispstpcpy (signature, CAR_SAFE (XD_NEXT_VALUE (object)));
object = CDR_SAFE (XD_NEXT_VALUE (object));
}
diff --git a/src/doc.c b/src/doc.c
index da6a9deb97..fdd7be6def 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -121,7 +121,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
if (minsize < 8)
minsize = 8;
name = SAFE_ALLOCA (minsize + SCHARS (file) + 8);
- lispstrcpy (name, docdir);
+ lispstpcpy (name, docdir);
strcat (name, SSDATA (file));
}
else
diff --git a/src/font.c b/src/font.c
index e8a13b7eed..1324b6e99c 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4266,7 +4266,7 @@ the consecutive wildcards are folded into one. */)
{
if (NILP (fold_wildcards))
return font_name;
- lispstrcpy (name, font_name);
+ lispstpcpy (name, font_name);
namelen = SBYTES (font_name);
goto done;
}
diff --git a/src/frame.c b/src/frame.c
index 51bd8fa7cf..5e2f351d77 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -4036,8 +4036,8 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li
/* Start with emacs.FRAMENAME for the name (the specific one)
and with `Emacs' for the class key (the general one). */
- lispstrcpy (name_key, Vx_resource_name);
- lispstrcpy (class_key, Vx_resource_class);
+ lispstpcpy (name_key, Vx_resource_name);
+ lispstpcpy (class_key, Vx_resource_class);
strcat (class_key, ".");
strcat (class_key, SSDATA (class));
diff --git a/src/lisp.h b/src/lisp.h
index 6ece4810b0..deb4635d03 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4463,12 +4463,15 @@ extern char *xstrdup (const char *) ATTRIBUTE_MALLOC;
extern char *xlispstrdup (Lisp_Object) ATTRIBUTE_MALLOC;
extern void dupstring (char **, char const *);
-/* Like strcpy but uses known length of a Lisp string. */
+/* Make DEST a copy of STRING's data. Return a pointer to DEST's terminating
+ null byte. This is like stpcpy, except the source is a Lisp string. */
INLINE char *
-lispstrcpy (const char *dest, Lisp_Object string)
+lispstpcpy (char *dest, Lisp_Object string)
{
- return memcpy ((void *) dest, SSDATA (string), SBYTES (string) + 1);
+ ptrdiff_t len = SBYTES (string);
+ memcpy (dest, SDATA (string), len + 1);
+ return dest + len;
}
extern void xputenv (const char *);
diff --git a/src/process.c b/src/process.c
index c614008378..f6484d0370 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2989,7 +2989,7 @@ usage: (make-network-process &rest ARGS) */)
address_un.sun_family = AF_LOCAL;
if (sizeof address_un.sun_path <= SBYTES (service))
error ("Service name too long");
- lispstrcpy (address_un.sun_path, service);
+ lispstpcpy (address_un.sun_path, service);
ai.ai_addr = (struct sockaddr *) &address_un;
ai.ai_addrlen = sizeof address_un;
goto open_socket;
@@ -3680,7 +3680,7 @@ network_interface_info (Lisp_Object ifname)
if (sizeof rq.ifr_name <= SBYTES (ifname))
error ("interface name too long");
- lispstrcpy (rq.ifr_name, ifname);
+ lispstpcpy (rq.ifr_name, ifname);
s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (s < 0)
diff --git a/src/w32fns.c b/src/w32fns.c
index a58a9ced85..2b77bb737b 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -5339,7 +5339,7 @@ terminate Emacs if we can't open the connection.
{
char basename[ MAX_PATH ], *str;
- lispstrcpy (basename, Vinvocation_name);
+ lispstpcpy (basename, Vinvocation_name);
str = strrchr (basename, '.');
if (str) *str = 0;
Vinvocation_name = build_string (basename);
diff --git a/src/w32proc.c b/src/w32proc.c
index 795df31c85..dc91910d9a 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1647,7 +1647,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
strcpy (cmdname, egetenv ("CMDPROXY"));
else
{
- lispstrcpy (cmdname, Vinvocation_directory);
+ lispstpcpy (cmdname, Vinvocation_directory);
strcat (cmdname, "cmdproxy.exe");
}
diff --git a/src/xfns.c b/src/xfns.c
index 7ecd15aea9..c2e39b5c0a 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4289,7 +4289,7 @@ select_visual (struct x_display_info *dpyinfo)
int i, class = -1;
XVisualInfo vinfo;
- lispstrcpy (s, value);
+ lispstpcpy (s, value);
dash = strchr (s, '-');
if (dash)
{
diff --git a/src/xfont.c b/src/xfont.c
index db0449716a..4dc26bb41b 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -541,7 +541,7 @@ xfont_list (struct frame *f, Lisp_Object spec)
if (STRINGP (XCAR (alter))
&& ((r - name) + SBYTES (XCAR (alter))) < 256)
{
- lispstrcpy (r, XCAR (alter));
+ lispstpcpy (r, XCAR (alter));
list = xfont_list_pattern (display, name, registry, script);
if (! NILP (list))
break;
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 5efbfaafa8..ed67a7d8e1 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -418,7 +418,7 @@ x_session_initialize (struct x_display_info *dpyinfo)
emacs_program[0] = '\0';
if (! EQ (Vinvocation_directory, Qnil))
- lispstrcpy (emacs_program, Vinvocation_directory);
+ lispstpcpy (emacs_program, Vinvocation_directory);
strcat (emacs_program, SSDATA (Vinvocation_name));
/* The SM protocol says all callbacks are mandatory, so set up all
diff --git a/src/xterm.c b/src/xterm.c
index 1b721b042b..e24e86ce41 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10902,8 +10902,9 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
dpyinfo->x_id = ++x_display_id;
dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name)
+ SBYTES (Vsystem_name) + 2);
- strcat (strcat (lispstrcpy (dpyinfo->x_id_name, Vinvocation_name), "@"),
- SSDATA (Vsystem_name));
+ char *nametail = lispstpcpy (dpyinfo->x_id_name, Vinvocation_name);
+ *nametail++ = '@';
+ lispstpcpy (nametail, Vsystem_name);
/* Figure out which modifier bits mean what. */
x_find_modifier_meanings (dpyinfo);