+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.
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
{
*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;
}
&& 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)
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. */
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;
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)
/* 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. */