[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r109164: Simple wrapper for make_unib
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r109164: Simple wrapper for make_unibyte_string, adjust font_open_by_name. |
Date: |
Fri, 20 Jul 2012 11:29:04 +0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 109164
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Fri 2012-07-20 11:29:04 +0400
message:
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.
added:
admin/coccinelle/unibyte_string.cocci
modified:
admin/ChangeLog
src/ChangeLog
src/dosfns.c
src/fileio.c
src/fns.c
src/font.c
src/font.h
src/frame.c
src/ftfont.c
src/lisp.h
src/process.c
src/sysdep.c
src/w32fns.c
src/xfns.c
=== modified file 'admin/ChangeLog'
--- a/admin/ChangeLog 2012-07-17 11:52:00 +0000
+++ b/admin/ChangeLog 2012-07-20 07:29:04 +0000
@@ -1,3 +1,8 @@
+2012-07-20 Dmitry Antipov <address@hidden>
+
+ * coccinelle/unibyte_string.cocci: Semantic patch to convert from
+ make_unibyte_string to build_unibyte_string where appropriate.
+
2012-07-17 Eli Zaretskii <address@hidden>
* CPP-DEFINES: Remove FILE_SYSTEM_CASE.
@@ -5,6 +10,7 @@
2012-07-17 Chong Yidong <address@hidden>
* Version 24.1 released.
+
2012-07-11 Paul Eggert <address@hidden>
Assume mkdir, perror, rename, rmdir, strerror.
=== added file 'admin/coccinelle/unibyte_string.cocci'
--- a/admin/coccinelle/unibyte_string.cocci 1970-01-01 00:00:00 +0000
+++ b/admin/coccinelle/unibyte_string.cocci 2012-07-20 07:29:04 +0000
@@ -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)
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-07-20 05:28:00 +0000
+++ b/src/ChangeLog 2012-07-20 07:29:04 +0000
@@ -1,5 +1,16 @@
2012-07-20 Dmitry Antipov <address@hidden>
+ 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 <address@hidden>
+
Cleanup calls to Fgarbage_collect.
* lisp.h (maybe_gc): New prototype.
(consing_since_gc, gc_relative_threshold, memory_full_cons_threshold):
=== modified file 'src/dosfns.c'
--- a/src/dosfns.c 2012-07-03 18:24:42 +0000
+++ b/src/dosfns.c 2012-07-20 07:29:04 +0000
@@ -562,7 +562,7 @@
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 @@
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);
=== modified file 'src/fileio.c'
--- a/src/fileio.c 2012-07-17 11:52:00 +0000
+++ b/src/fileio.c 2012-07-20 07:29:04 +0000
@@ -159,8 +159,7 @@
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 @@
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;
=== modified file 'src/fns.c'
--- a/src/fns.c 2012-07-16 04:47:31 +0000
+++ b/src/fns.c 2012-07-20 07:29:04 +0000
@@ -2818,7 +2818,7 @@
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 @@
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));
}
=== modified file 'src/font.c'
--- a/src/font.c 2012-07-15 07:57:54 +0000
+++ b/src/font.c 2012-07-20 07:29:04 +0000
@@ -3350,13 +3350,13 @@
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 (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;
=== modified file 'src/font.h'
--- a/src/font.h 2012-07-11 06:14:19 +0000
+++ b/src/font.h 2012-07-20 07:29:04 +0000
@@ -771,7 +771,7 @@
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);
=== modified file 'src/frame.c'
--- a/src/frame.c 2012-07-18 08:11:08 +0000
+++ b/src/frame.c 2012-07-20 07:29:04 +0000
@@ -3167,16 +3167,14 @@
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);
=== modified file 'src/ftfont.c'
--- a/src/ftfont.c 2012-07-11 06:14:19 +0000
+++ b/src/ftfont.c 2012-07-20 07:29:04 +0000
@@ -211,7 +211,7 @@
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))
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2012-07-20 05:28:00 +0000
+++ b/src/lisp.h 2012-07-20 07:29:04 +0000
@@ -2609,6 +2609,15 @@
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);
=== modified file 'src/process.c'
--- a/src/process.c 2012-07-13 00:07:29 +0000
+++ b/src/process.c 2012-07-20 07:29:04 +0000
@@ -497,7 +497,7 @@
{
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));
=== modified file 'src/sysdep.c'
--- a/src/sysdep.c 2012-07-11 07:05:21 +0000
+++ b/src/sysdep.c 2012-07-20 07:29:04 +0000
@@ -3092,7 +3092,7 @@
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);
=== modified file 'src/w32fns.c'
--- a/src/w32fns.c 2012-07-11 04:31:53 +0000
+++ b/src/w32fns.c 2012-07-20 07:29:04 +0000
@@ -4036,7 +4036,7 @@
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 @@
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);
}
=== modified file 'src/xfns.c'
--- a/src/xfns.c 2012-07-11 04:31:53 +0000
+++ b/src/xfns.c 2012-07-20 07:29:04 +0000
@@ -2956,7 +2956,7 @@
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 @@
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;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r109164: Simple wrapper for make_unibyte_string, adjust font_open_by_name.,
Dmitry Antipov <=