mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-25 15:00:45 -08:00
Simple wrapper for make_unibyte_string, adjust font_open_by_name.
* 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.
This commit is contained in:
parent
765e61e391
commit
d7ea76b4f3
15 changed files with 51 additions and 23 deletions
|
|
@ -1,3 +1,8 @@
|
|||
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.
|
||||
|
|
@ -5,6 +10,7 @@
|
|||
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.
|
||||
|
|
|
|||
6
admin/coccinelle/unibyte_string.cocci
Normal file
6
admin/coccinelle/unibyte_string.cocci
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// make_unibyte_string (str, strlen (str)) -> build_unibyte_string (str)
|
||||
@@
|
||||
identifier I;
|
||||
@@
|
||||
- make_unibyte_string (I, strlen (I))
|
||||
+ build_unibyte_string (I)
|
||||
|
|
@ -1,3 +1,14 @@
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ system_process_attributes (Lisp_Object pid)
|
|||
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);
|
||||
|
|
@ -630,7 +630,7 @@ system_process_attributes (Lisp_Object pid)
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -159,8 +159,7 @@ report_file_error (const char *string, Lisp_Object data)
|
|||
|
||||
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)
|
||||
|
|
@ -1658,7 +1657,7 @@ those `/' is discarded. */)
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -2818,7 +2818,7 @@ The data read from the system are decoded using `locale-coding-system'. */)
|
|||
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),
|
||||
|
|
@ -2842,7 +2842,7 @@ The data read from the system are decoded using `locale-coding-system'. */)
|
|||
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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3350,13 +3350,13 @@ font_open_by_spec (FRAME_PTR f, Lisp_Object spec)
|
|||
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. */
|
||||
|
|
@ -4878,7 +4878,7 @@ If the named font is not yet loaded, return nil. */)
|
|||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -771,7 +771,7 @@ extern void font_prepare_for_face (FRAME_PTR f, struct face *face);
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -3167,16 +3167,14 @@ x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra)
|
|||
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))
|
||||
|
|
|
|||
|
|
@ -2609,6 +2609,15 @@ extern Lisp_Object make_string (const char *, ptrdiff_t);
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ status_message (struct Lisp_Process *p)
|
|||
{
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -3092,7 +3092,7 @@ system_process_attributes (Lisp_Object pid)
|
|||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -4036,7 +4036,7 @@ x_default_font_parameter (struct frame *f, Lisp_Object parms)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
@ -6197,8 +6197,7 @@ an integer representing a ShowWindow flag:
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2956,7 +2956,7 @@ x_default_font_parameter (struct frame *f, Lisp_Object parms)
|
|||
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))
|
||||
|
|
@ -2986,7 +2986,7 @@ x_default_font_parameter (struct frame *f, Lisp_Object parms)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue