* src/lisp.h (build_unibyte_string): New function.
* src/dosfns.c, src/fileio.c, src/fns.c, src/ftfont.c, src/process.c:
* src/sysdep.c, src/w32fns.c, src/xfns.c: Use it.
* src/font.c (font_open_by_name): Change 2nd and 3rd args to the only arg
of type Lisp_Object to avoid redundant calls to make_unibyte_string.
Adjust users accordingly.
* src/font.h (font_open_by_name): Adjust prototype.
* admin/coccinelle/unibyte_string.cocci: Semantic patch to convert from
make_unibyte_string to build_unibyte_string where appropriate.
+2012-07-20 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * coccinelle/unibyte_string.cocci: Semantic patch to convert from
+ make_unibyte_string to build_unibyte_string where appropriate.
+
2012-07-17 Eli Zaretskii <eliz@gnu.org>
* CPP-DEFINES: Remove FILE_SYSTEM_CASE.
2012-07-17 Chong Yidong <cyd@gnu.org>
* Version 24.1 released.
+
2012-07-11 Paul Eggert <eggert@cs.ucla.edu>
Assume mkdir, perror, rename, rmdir, strerror.
--- /dev/null
+// make_unibyte_string (str, strlen (str)) -> build_unibyte_string (str)
+@@
+identifier I;
+@@
+- make_unibyte_string (I, strlen (I))
++ build_unibyte_string (I)
+2012-07-20 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Simple wrapper for make_unibyte_string, adjust font_open_by_name.
+ * lisp.h (build_unibyte_string): New function.
+ * dosfns.c, fileio.c, fns.c, ftfont.c, process.c:
+ * sysdep.c, w32fns.c, xfns.c: Use it.
+ * font.c (font_open_by_name): Change 2nd and 3rd args to the only arg
+ of type Lisp_Object to avoid redundant calls to make_unibyte_string.
+ Adjust users accordingly.
+ * font.h (font_open_by_name): Adjust prototype.
+
2012-07-20 Dmitry Antipov <dmantipov@yandex.ru>
Cleanup calls to Fgarbage_collect.
attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
strcpy (cmd, basename (__crt0_argv[0]));
/* Command name is encoded in locale-coding-system; decode it. */
- cmd_str = make_unibyte_string (cmd, strlen (cmd));
+ cmd_str = build_unibyte_string (cmd);
decoded_cmd = code_convert_string_norecord (cmd_str,
Vlocale_coding_system, 0);
attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs);
q[-1] = '\0';
/* Command line is encoded in locale-coding-system; decode it. */
- cmd_str = make_unibyte_string (cmdline, strlen (cmdline));
+ cmd_str = build_unibyte_string (cmdline);
decoded_cmd = code_convert_string_norecord (cmd_str,
Vlocale_coding_system, 0);
xfree (cmdline);
synchronize_system_messages_locale ();
str = strerror (errorno);
- errstring = code_convert_string_norecord (make_unibyte_string (str,
- strlen (str)),
+ errstring = code_convert_string_norecord (build_unibyte_string (str),
Vlocale_coding_system, 0);
while (1)
env variables twice should be acceptable. Note that
decoding may cause a garbage collect. */
Lisp_Object orig, decoded;
- orig = make_unibyte_string (o, strlen (o));
+ orig = build_unibyte_string (o);
decoded = DECODE_FILE (orig);
total += SBYTES (decoded);
substituted = 1;
for (i = 0; i < 7; i++)
{
str = nl_langinfo (days[i]);
- val = make_unibyte_string (str, strlen (str));
+ val = build_unibyte_string (str);
/* Fixme: Is this coding system necessarily right, even if
it is consistent with CODESET? If not, what to do? */
Faset (v, make_number (i),
for (i = 0; i < 12; i++)
{
str = nl_langinfo (months[i]);
- val = make_unibyte_string (str, strlen (str));
+ val = build_unibyte_string (str);
Faset (v, make_number (i),
code_convert_string_norecord (val, Vlocale_coding_system, 0));
}
found, return Qnil. */
Lisp_Object
-font_open_by_name (FRAME_PTR f, const char *name, ptrdiff_t len)
+font_open_by_name (FRAME_PTR f, Lisp_Object name)
{
Lisp_Object args[2];
Lisp_Object spec, ret;
args[0] = QCname;
- args[1] = make_unibyte_string (name, len);
+ args[1] = name;
spec = Ffont_spec (2, args);
ret = font_open_by_spec (f, spec);
/* Do not lose name originally put in. */
if (fontset >= 0)
name = fontset_ascii (fontset);
- font_object = font_open_by_name (f, SSDATA (name), SBYTES (name));
+ font_object = font_open_by_name (f, name);
}
else if (FONT_OBJECT_P (name))
font_object = name;
extern void font_done_for_face (FRAME_PTR f, struct face *face);
extern Lisp_Object font_open_by_spec (FRAME_PTR f, Lisp_Object spec);
-extern Lisp_Object font_open_by_name (FRAME_PTR f, const char *name, ptrdiff_t len);
+extern Lisp_Object font_open_by_name (FRAME_PTR f, Lisp_Object name);
extern Lisp_Object font_intern_prop (const char *str, ptrdiff_t len,
int force_symbol);
fontset = fs_query_fontset (arg, 0);
if (fontset < 0)
{
- font_object = font_open_by_name (f, SSDATA (arg), SBYTES (arg));
+ font_object = font_open_by_name (f, arg);
if (NILP (font_object))
error ("Font `%s' is not defined", SSDATA (arg));
arg = AREF (font_object, FONT_NAME_INDEX);
}
else if (fontset > 0)
{
- Lisp_Object ascii_font = fontset_ascii (fontset);
-
- font_object = font_open_by_name (f, SSDATA (ascii_font), SBYTES (ascii_font));
+ font_object = font_open_by_name (f, fontset_ascii (fontset));
if (NILP (font_object))
error ("Font `%s' is not defined", SDATA (arg));
arg = AREF (font_object, FONT_NAME_INDEX);
return Qnil;
file = (char *) str;
- key = Fcons (make_unibyte_string (file, strlen (file)), make_number (idx));
+ key = Fcons (build_unibyte_string (file), make_number (idx));
cache = ftfont_lookup_cache (key, FTFONT_CACHE_FOR_ENTITY);
entity = XCAR (cache);
if (! NILP (entity))
extern Lisp_Object make_formatted_string (char *, const char *, ...)
ATTRIBUTE_FORMAT_PRINTF (2, 3);
extern Lisp_Object make_unibyte_string (const char *, ptrdiff_t);
+
+/* Make unibyte string from C string when the length isn't known. */
+
+static inline Lisp_Object
+build_unibyte_string (const char *str)
+{
+ return make_unibyte_string (str, strlen (str));
+}
+
extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t);
extern Lisp_Object make_event_array (int, Lisp_Object *);
extern Lisp_Object make_uninit_string (EMACS_INT);
{
int c1, c2;
- string = make_unibyte_string (signame, strlen (signame));
+ string = build_unibyte_string (signame);
if (! NILP (Vlocale_coding_system))
string = (code_convert_string_norecord
(string, Vlocale_coding_system, 0));
decoded_comm =
(code_convert_string_norecord
- (make_unibyte_string (args, strlen (args)),
+ (build_unibyte_string (args),
Vlocale_coding_system, 0));
attrs = Fcons (Fcons (Qargs, decoded_comm), attrs);
for (i = 0; names[i]; i++)
{
- font = font_open_by_name (f, names[i], strlen (names[i]));
+ font = font_open_by_name (f, build_unibyte_string (names[i]));
if (! NILP (font))
break;
}
if (!NILP (Vlocale_coding_system))
{
Lisp_Object decoded =
- code_convert_string_norecord (make_unibyte_string (errstr,
- strlen (errstr)),
+ code_convert_string_norecord (build_unibyte_string (errstr),
Vlocale_coding_system, 0);
errstr = SSDATA (decoded);
}
read yet. */
const char *system_font = xsettings_get_system_font ();
if (system_font)
- font = font_open_by_name (f, system_font, strlen (system_font));
+ font = font_open_by_name (f, build_unibyte_string (system_font));
}
if (NILP (font))
for (i = 0; names[i]; i++)
{
- font = font_open_by_name (f, names[i], strlen (names[i]));
+ font = font_open_by_name (f, build_unibyte_string (names[i]));
if (! NILP (font))
break;
}