emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using stpcpy


From: Dmitry Antipov
Subject: Re: Using stpcpy
Date: Tue, 23 Dec 2014 13:39:51 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 12/23/2014 09:47 AM, Paul Eggert wrote:

Something like the attached patch, perhaps?  Tested on
both GNU/Linux and Solaris 10 (which lacks stpcpy).

Not quite; in particular, I would prefer (for example, in doc.c):

@@ -137,8 +136,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool 
definition)
        {
          /* Preparing to dump; DOC file is probably not installed.
             So check in ../etc.  */
-         strcpy (name, "../etc/");
-         strcat (name, SSDATA (file));
+         lispstpcpy (stpcpy (name, "../etc/"), file);

rather than:

@@ -137,8 +137,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool 
definition)
        {
          /* Preparing to dump; DOC file is probably not installed.
             So check in ../etc.  */
-         strcpy (name, "../etc/");
-         strcat (name, SSDATA (file));
+         strcpy (stpcpy (name, "../etc/"), SSDATA (file));

(because lispstpcpy can use known length of a Lisp_String and so call memcpy,
which should be faster than strcpy).

Dmitry




reply via email to

[Prev in Thread] Current Thread [Next in Thread]