Commit 4620e6bc authored by Paul Eggert's avatar Paul Eggert
Browse files

Fix some slow uses and misuses of strcat.

* doc.c (get_doc_string):
* gtkutil.c (get_utf8_string):
* xsmfns.c (x_session_initialize):
Avoid recomputation of string length.
* ftfont.c (ftfont_spec_pattern):
* xfns.c (xic_create_fontsetname):
Don't assume output buffer is initially zero.
parent 7d760fd8
2014-09-24 Paul Eggert <eggert@cs.ucla.edu>
Fix some slow uses and misuses of strcat.
* doc.c (get_doc_string):
* gtkutil.c (get_utf8_string):
* xsmfns.c (x_session_initialize):
Avoid recomputation of string length.
* ftfont.c (ftfont_spec_pattern):
* xfns.c (xic_create_fontsetname):
Don't assume output buffer is initially zero.
2014-09-23 Paul Eggert <eggert@cs.ucla.edu>
 
* lisp.h (lispstpcpy): Rename from lispstrcpy, and act like stpcpy.
......
......@@ -121,8 +121,8 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
if (minsize < 8)
minsize = 8;
name = SAFE_ALLOCA (minsize + SCHARS (file) + 8);
lispstpcpy (name, docdir);
strcat (name, SSDATA (file));
char *z = lispstpcpy (name, docdir);
strcpy (z, SSDATA (file));
}
else
{
......
......@@ -804,7 +804,7 @@ ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **ots
*otspec = ftfont_get_open_type_spec (val);
if (! *otspec)
return NULL;
strcat (otlayout, "otlayout:");
strcpy (otlayout, "otlayout:");
OTF_TAG_STR ((*otspec)->script_tag, otlayout + 9);
script = (*otspec)->script;
}
......
......@@ -508,16 +508,16 @@ get_utf8_string (const char *str)
&& err->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE)
{
memcpy (up, p, bytes_written);
sprintf (up + bytes_written, "\\%03o", p[bytes_written]);
up += bytes_written+4;
p += bytes_written+1;
up += bytes_written;
up += sprintf (up, "\\%03o", p[bytes_written]);
p += bytes_written + 1;
g_error_free (err);
err = NULL;
}
if (cp)
{
strcat (utf8_str, cp);
strcpy (up, cp);
g_free (cp);
}
if (err)
......
......@@ -1786,7 +1786,7 @@ xic_create_fontsetname (const char *base_fontname, int motif)
len = p - base_fontname + strlen (allcs) + 1;
font_allcs = alloca (len);
memcpy (font_allcs, base_fontname, p - base_fontname);
strcat (font_allcs, allcs);
strcpy (font_allcs + (p - base_fontname), allcs);
/* Build the font spec that matches all families and
add-styles. */
......@@ -1794,7 +1794,7 @@ xic_create_fontsetname (const char *base_fontname, int motif)
font_allfamilies = alloca (len);
strcpy (font_allfamilies, allfamilies);
memcpy (font_allfamilies + strlen (allfamilies), p1, p - p1);
strcat (font_allfamilies, allcs);
strcpy (font_allfamilies + strlen (allfamilies) + (p - p1), allcs);
/* Build the font spec that matches all. */
len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1;
......@@ -1802,7 +1802,8 @@ xic_create_fontsetname (const char *base_fontname, int motif)
strcpy (font_all, allfamilies);
strcat (font_all, all);
memcpy (font_all + strlen (all) + strlen (allfamilies), p2, p - p2);
strcat (font_all, allcs);
strcpy (font_all + strlen (all) + strlen (allfamilies) + (p - p2),
allcs);
/* Build the actual font set name. */
len = strlen (base_fontname) + strlen (font_allcs)
......
......@@ -415,11 +415,11 @@ x_session_initialize (struct x_display_info *dpyinfo)
/* This malloc will not be freed, but it is only done once, and hopefully
not very large */
emacs_program = xmalloc (name_len + 1);
emacs_program[0] = '\0';
char *z = emacs_program;
if (! EQ (Vinvocation_directory, Qnil))
lispstpcpy (emacs_program, Vinvocation_directory);
strcat (emacs_program, SSDATA (Vinvocation_name));
z = lispstpcpy (z, Vinvocation_directory);
lispstpcpy (z, Vinvocation_name);
/* The SM protocol says all callbacks are mandatory, so set up all
here and in the mask passed to SmcOpenConnection. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment