diff options
| author | Dmitry Antipov | 2012-07-20 11:29:04 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-20 11:29:04 +0400 |
| commit | d7ea76b4f34c4e2c43bf0b1deeedde354ca540f7 (patch) | |
| tree | ac3cb2ab6d00e89542afc9a5290191e549ce1d81 /src | |
| parent | 765e61e391ee0937ff6b30510b6c4651064fe38e (diff) | |
| download | emacs-d7ea76b4f34c4e2c43bf0b1deeedde354ca540f7.tar.gz emacs-d7ea76b4f34c4e2c43bf0b1deeedde354ca540f7.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/dosfns.c | 4 | ||||
| -rw-r--r-- | src/fileio.c | 5 | ||||
| -rw-r--r-- | src/fns.c | 4 | ||||
| -rw-r--r-- | src/font.c | 6 | ||||
| -rw-r--r-- | src/font.h | 2 | ||||
| -rw-r--r-- | src/frame.c | 6 | ||||
| -rw-r--r-- | src/ftfont.c | 2 | ||||
| -rw-r--r-- | src/lisp.h | 9 | ||||
| -rw-r--r-- | src/process.c | 2 | ||||
| -rw-r--r-- | src/sysdep.c | 2 | ||||
| -rw-r--r-- | src/w32fns.c | 5 | ||||
| -rw-r--r-- | src/xfns.c | 4 |
13 files changed, 39 insertions, 23 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 909fb03c488..8242a35e9ec 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,16 @@ | |||
| 1 | 2012-07-20 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2012-07-20 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | Simple wrapper for make_unibyte_string, adjust font_open_by_name. | ||
| 4 | * lisp.h (build_unibyte_string): New function. | ||
| 5 | * dosfns.c, fileio.c, fns.c, ftfont.c, process.c: | ||
| 6 | * sysdep.c, w32fns.c, xfns.c: Use it. | ||
| 7 | * font.c (font_open_by_name): Change 2nd and 3rd args to the only arg | ||
| 8 | of type Lisp_Object to avoid redundant calls to make_unibyte_string. | ||
| 9 | Adjust users accordingly. | ||
| 10 | * font.h (font_open_by_name): Adjust prototype. | ||
| 11 | |||
| 12 | 2012-07-20 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 13 | |||
| 3 | Cleanup calls to Fgarbage_collect. | 14 | Cleanup calls to Fgarbage_collect. |
| 4 | * lisp.h (maybe_gc): New prototype. | 15 | * lisp.h (maybe_gc): New prototype. |
| 5 | (consing_since_gc, gc_relative_threshold, memory_full_cons_threshold): | 16 | (consing_since_gc, gc_relative_threshold, memory_full_cons_threshold): |
diff --git a/src/dosfns.c b/src/dosfns.c index ee28801e841..6fd1b52e252 100644 --- a/src/dosfns.c +++ b/src/dosfns.c | |||
| @@ -562,7 +562,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 562 | attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs); | 562 | attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs); |
| 563 | strcpy (cmd, basename (__crt0_argv[0])); | 563 | strcpy (cmd, basename (__crt0_argv[0])); |
| 564 | /* Command name is encoded in locale-coding-system; decode it. */ | 564 | /* Command name is encoded in locale-coding-system; decode it. */ |
| 565 | cmd_str = make_unibyte_string (cmd, strlen (cmd)); | 565 | cmd_str = build_unibyte_string (cmd); |
| 566 | decoded_cmd = code_convert_string_norecord (cmd_str, | 566 | decoded_cmd = code_convert_string_norecord (cmd_str, |
| 567 | Vlocale_coding_system, 0); | 567 | Vlocale_coding_system, 0); |
| 568 | attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs); | 568 | attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs); |
| @@ -630,7 +630,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 630 | q[-1] = '\0'; | 630 | q[-1] = '\0'; |
| 631 | 631 | ||
| 632 | /* Command line is encoded in locale-coding-system; decode it. */ | 632 | /* Command line is encoded in locale-coding-system; decode it. */ |
| 633 | cmd_str = make_unibyte_string (cmdline, strlen (cmdline)); | 633 | cmd_str = build_unibyte_string (cmdline); |
| 634 | decoded_cmd = code_convert_string_norecord (cmd_str, | 634 | decoded_cmd = code_convert_string_norecord (cmd_str, |
| 635 | Vlocale_coding_system, 0); | 635 | Vlocale_coding_system, 0); |
| 636 | xfree (cmdline); | 636 | xfree (cmdline); |
diff --git a/src/fileio.c b/src/fileio.c index 185dd650438..a13fe94e416 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -159,8 +159,7 @@ report_file_error (const char *string, Lisp_Object data) | |||
| 159 | 159 | ||
| 160 | synchronize_system_messages_locale (); | 160 | synchronize_system_messages_locale (); |
| 161 | str = strerror (errorno); | 161 | str = strerror (errorno); |
| 162 | errstring = code_convert_string_norecord (make_unibyte_string (str, | 162 | errstring = code_convert_string_norecord (build_unibyte_string (str), |
| 163 | strlen (str)), | ||
| 164 | Vlocale_coding_system, 0); | 163 | Vlocale_coding_system, 0); |
| 165 | 164 | ||
| 166 | while (1) | 165 | while (1) |
| @@ -1658,7 +1657,7 @@ those `/' is discarded. */) | |||
| 1658 | env variables twice should be acceptable. Note that | 1657 | env variables twice should be acceptable. Note that |
| 1659 | decoding may cause a garbage collect. */ | 1658 | decoding may cause a garbage collect. */ |
| 1660 | Lisp_Object orig, decoded; | 1659 | Lisp_Object orig, decoded; |
| 1661 | orig = make_unibyte_string (o, strlen (o)); | 1660 | orig = build_unibyte_string (o); |
| 1662 | decoded = DECODE_FILE (orig); | 1661 | decoded = DECODE_FILE (orig); |
| 1663 | total += SBYTES (decoded); | 1662 | total += SBYTES (decoded); |
| 1664 | substituted = 1; | 1663 | substituted = 1; |
| @@ -2818,7 +2818,7 @@ The data read from the system are decoded using `locale-coding-system'. */) | |||
| 2818 | for (i = 0; i < 7; i++) | 2818 | for (i = 0; i < 7; i++) |
| 2819 | { | 2819 | { |
| 2820 | str = nl_langinfo (days[i]); | 2820 | str = nl_langinfo (days[i]); |
| 2821 | val = make_unibyte_string (str, strlen (str)); | 2821 | val = build_unibyte_string (str); |
| 2822 | /* Fixme: Is this coding system necessarily right, even if | 2822 | /* Fixme: Is this coding system necessarily right, even if |
| 2823 | it is consistent with CODESET? If not, what to do? */ | 2823 | it is consistent with CODESET? If not, what to do? */ |
| 2824 | Faset (v, make_number (i), | 2824 | Faset (v, make_number (i), |
| @@ -2842,7 +2842,7 @@ The data read from the system are decoded using `locale-coding-system'. */) | |||
| 2842 | for (i = 0; i < 12; i++) | 2842 | for (i = 0; i < 12; i++) |
| 2843 | { | 2843 | { |
| 2844 | str = nl_langinfo (months[i]); | 2844 | str = nl_langinfo (months[i]); |
| 2845 | val = make_unibyte_string (str, strlen (str)); | 2845 | val = build_unibyte_string (str); |
| 2846 | Faset (v, make_number (i), | 2846 | Faset (v, make_number (i), |
| 2847 | code_convert_string_norecord (val, Vlocale_coding_system, 0)); | 2847 | code_convert_string_norecord (val, Vlocale_coding_system, 0)); |
| 2848 | } | 2848 | } |
diff --git a/src/font.c b/src/font.c index 5b01a1f44d6..2c0296aa8c5 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -3350,13 +3350,13 @@ font_open_by_spec (FRAME_PTR f, Lisp_Object spec) | |||
| 3350 | found, return Qnil. */ | 3350 | found, return Qnil. */ |
| 3351 | 3351 | ||
| 3352 | Lisp_Object | 3352 | Lisp_Object |
| 3353 | font_open_by_name (FRAME_PTR f, const char *name, ptrdiff_t len) | 3353 | font_open_by_name (FRAME_PTR f, Lisp_Object name) |
| 3354 | { | 3354 | { |
| 3355 | Lisp_Object args[2]; | 3355 | Lisp_Object args[2]; |
| 3356 | Lisp_Object spec, ret; | 3356 | Lisp_Object spec, ret; |
| 3357 | 3357 | ||
| 3358 | args[0] = QCname; | 3358 | args[0] = QCname; |
| 3359 | args[1] = make_unibyte_string (name, len); | 3359 | args[1] = name; |
| 3360 | spec = Ffont_spec (2, args); | 3360 | spec = Ffont_spec (2, args); |
| 3361 | ret = font_open_by_spec (f, spec); | 3361 | ret = font_open_by_spec (f, spec); |
| 3362 | /* Do not lose name originally put in. */ | 3362 | /* Do not lose name originally put in. */ |
| @@ -4878,7 +4878,7 @@ If the named font is not yet loaded, return nil. */) | |||
| 4878 | 4878 | ||
| 4879 | if (fontset >= 0) | 4879 | if (fontset >= 0) |
| 4880 | name = fontset_ascii (fontset); | 4880 | name = fontset_ascii (fontset); |
| 4881 | font_object = font_open_by_name (f, SSDATA (name), SBYTES (name)); | 4881 | font_object = font_open_by_name (f, name); |
| 4882 | } | 4882 | } |
| 4883 | else if (FONT_OBJECT_P (name)) | 4883 | else if (FONT_OBJECT_P (name)) |
| 4884 | font_object = name; | 4884 | font_object = name; |
diff --git a/src/font.h b/src/font.h index b4e994397de..2e374571c67 100644 --- a/src/font.h +++ b/src/font.h | |||
| @@ -771,7 +771,7 @@ extern void font_prepare_for_face (FRAME_PTR f, struct face *face); | |||
| 771 | extern void font_done_for_face (FRAME_PTR f, struct face *face); | 771 | extern void font_done_for_face (FRAME_PTR f, struct face *face); |
| 772 | 772 | ||
| 773 | extern Lisp_Object font_open_by_spec (FRAME_PTR f, Lisp_Object spec); | 773 | extern Lisp_Object font_open_by_spec (FRAME_PTR f, Lisp_Object spec); |
| 774 | extern Lisp_Object font_open_by_name (FRAME_PTR f, const char *name, ptrdiff_t len); | 774 | extern Lisp_Object font_open_by_name (FRAME_PTR f, Lisp_Object name); |
| 775 | 775 | ||
| 776 | extern Lisp_Object font_intern_prop (const char *str, ptrdiff_t len, | 776 | extern Lisp_Object font_intern_prop (const char *str, ptrdiff_t len, |
| 777 | int force_symbol); | 777 | int force_symbol); |
diff --git a/src/frame.c b/src/frame.c index 9668ea4d831..bf2b180f2d3 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -3167,16 +3167,14 @@ x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 3167 | fontset = fs_query_fontset (arg, 0); | 3167 | fontset = fs_query_fontset (arg, 0); |
| 3168 | if (fontset < 0) | 3168 | if (fontset < 0) |
| 3169 | { | 3169 | { |
| 3170 | font_object = font_open_by_name (f, SSDATA (arg), SBYTES (arg)); | 3170 | font_object = font_open_by_name (f, arg); |
| 3171 | if (NILP (font_object)) | 3171 | if (NILP (font_object)) |
| 3172 | error ("Font `%s' is not defined", SSDATA (arg)); | 3172 | error ("Font `%s' is not defined", SSDATA (arg)); |
| 3173 | arg = AREF (font_object, FONT_NAME_INDEX); | 3173 | arg = AREF (font_object, FONT_NAME_INDEX); |
| 3174 | } | 3174 | } |
| 3175 | else if (fontset > 0) | 3175 | else if (fontset > 0) |
| 3176 | { | 3176 | { |
| 3177 | Lisp_Object ascii_font = fontset_ascii (fontset); | 3177 | font_object = font_open_by_name (f, fontset_ascii (fontset)); |
| 3178 | |||
| 3179 | font_object = font_open_by_name (f, SSDATA (ascii_font), SBYTES (ascii_font)); | ||
| 3180 | if (NILP (font_object)) | 3178 | if (NILP (font_object)) |
| 3181 | error ("Font `%s' is not defined", SDATA (arg)); | 3179 | error ("Font `%s' is not defined", SDATA (arg)); |
| 3182 | arg = AREF (font_object, FONT_NAME_INDEX); | 3180 | arg = AREF (font_object, FONT_NAME_INDEX); |
diff --git a/src/ftfont.c b/src/ftfont.c index 131a27f76e0..e16f967f596 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -211,7 +211,7 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) | |||
| 211 | return Qnil; | 211 | return Qnil; |
| 212 | 212 | ||
| 213 | file = (char *) str; | 213 | file = (char *) str; |
| 214 | key = Fcons (make_unibyte_string (file, strlen (file)), make_number (idx)); | 214 | key = Fcons (build_unibyte_string (file), make_number (idx)); |
| 215 | cache = ftfont_lookup_cache (key, FTFONT_CACHE_FOR_ENTITY); | 215 | cache = ftfont_lookup_cache (key, FTFONT_CACHE_FOR_ENTITY); |
| 216 | entity = XCAR (cache); | 216 | entity = XCAR (cache); |
| 217 | if (! NILP (entity)) | 217 | if (! NILP (entity)) |
diff --git a/src/lisp.h b/src/lisp.h index 471b8277b82..2a598900146 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2609,6 +2609,15 @@ extern Lisp_Object make_string (const char *, ptrdiff_t); | |||
| 2609 | extern Lisp_Object make_formatted_string (char *, const char *, ...) | 2609 | extern Lisp_Object make_formatted_string (char *, const char *, ...) |
| 2610 | ATTRIBUTE_FORMAT_PRINTF (2, 3); | 2610 | ATTRIBUTE_FORMAT_PRINTF (2, 3); |
| 2611 | extern Lisp_Object make_unibyte_string (const char *, ptrdiff_t); | 2611 | extern Lisp_Object make_unibyte_string (const char *, ptrdiff_t); |
| 2612 | |||
| 2613 | /* Make unibyte string from C string when the length isn't known. */ | ||
| 2614 | |||
| 2615 | static inline Lisp_Object | ||
| 2616 | build_unibyte_string (const char *str) | ||
| 2617 | { | ||
| 2618 | return make_unibyte_string (str, strlen (str)); | ||
| 2619 | } | ||
| 2620 | |||
| 2612 | extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t); | 2621 | extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t); |
| 2613 | extern Lisp_Object make_event_array (int, Lisp_Object *); | 2622 | extern Lisp_Object make_event_array (int, Lisp_Object *); |
| 2614 | extern Lisp_Object make_uninit_string (EMACS_INT); | 2623 | extern Lisp_Object make_uninit_string (EMACS_INT); |
diff --git a/src/process.c b/src/process.c index ceb5c81d32b..1b66bef03a8 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -497,7 +497,7 @@ status_message (struct Lisp_Process *p) | |||
| 497 | { | 497 | { |
| 498 | int c1, c2; | 498 | int c1, c2; |
| 499 | 499 | ||
| 500 | string = make_unibyte_string (signame, strlen (signame)); | 500 | string = build_unibyte_string (signame); |
| 501 | if (! NILP (Vlocale_coding_system)) | 501 | if (! NILP (Vlocale_coding_system)) |
| 502 | string = (code_convert_string_norecord | 502 | string = (code_convert_string_norecord |
| 503 | (string, Vlocale_coding_system, 0)); | 503 | (string, Vlocale_coding_system, 0)); |
diff --git a/src/sysdep.c b/src/sysdep.c index 7d0855b543c..6ce583b3d53 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -3092,7 +3092,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 3092 | 3092 | ||
| 3093 | decoded_comm = | 3093 | decoded_comm = |
| 3094 | (code_convert_string_norecord | 3094 | (code_convert_string_norecord |
| 3095 | (make_unibyte_string (args, strlen (args)), | 3095 | (build_unibyte_string (args), |
| 3096 | Vlocale_coding_system, 0)); | 3096 | Vlocale_coding_system, 0)); |
| 3097 | 3097 | ||
| 3098 | attrs = Fcons (Fcons (Qargs, decoded_comm), attrs); | 3098 | attrs = Fcons (Fcons (Qargs, decoded_comm), attrs); |
diff --git a/src/w32fns.c b/src/w32fns.c index dac83ab6ae1..06938e3124b 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -4036,7 +4036,7 @@ x_default_font_parameter (struct frame *f, Lisp_Object parms) | |||
| 4036 | 4036 | ||
| 4037 | for (i = 0; names[i]; i++) | 4037 | for (i = 0; names[i]; i++) |
| 4038 | { | 4038 | { |
| 4039 | font = font_open_by_name (f, names[i], strlen (names[i])); | 4039 | font = font_open_by_name (f, build_unibyte_string (names[i])); |
| 4040 | if (! NILP (font)) | 4040 | if (! NILP (font)) |
| 4041 | break; | 4041 | break; |
| 4042 | } | 4042 | } |
| @@ -6197,8 +6197,7 @@ an integer representing a ShowWindow flag: | |||
| 6197 | if (!NILP (Vlocale_coding_system)) | 6197 | if (!NILP (Vlocale_coding_system)) |
| 6198 | { | 6198 | { |
| 6199 | Lisp_Object decoded = | 6199 | Lisp_Object decoded = |
| 6200 | code_convert_string_norecord (make_unibyte_string (errstr, | 6200 | code_convert_string_norecord (build_unibyte_string (errstr), |
| 6201 | strlen (errstr)), | ||
| 6202 | Vlocale_coding_system, 0); | 6201 | Vlocale_coding_system, 0); |
| 6203 | errstr = SSDATA (decoded); | 6202 | errstr = SSDATA (decoded); |
| 6204 | } | 6203 | } |
diff --git a/src/xfns.c b/src/xfns.c index a0229919aa0..e431651d93a 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -2956,7 +2956,7 @@ x_default_font_parameter (struct frame *f, Lisp_Object parms) | |||
| 2956 | read yet. */ | 2956 | read yet. */ |
| 2957 | const char *system_font = xsettings_get_system_font (); | 2957 | const char *system_font = xsettings_get_system_font (); |
| 2958 | if (system_font) | 2958 | if (system_font) |
| 2959 | font = font_open_by_name (f, system_font, strlen (system_font)); | 2959 | font = font_open_by_name (f, build_unibyte_string (system_font)); |
| 2960 | } | 2960 | } |
| 2961 | 2961 | ||
| 2962 | if (NILP (font)) | 2962 | if (NILP (font)) |
| @@ -2986,7 +2986,7 @@ x_default_font_parameter (struct frame *f, Lisp_Object parms) | |||
| 2986 | 2986 | ||
| 2987 | for (i = 0; names[i]; i++) | 2987 | for (i = 0; names[i]; i++) |
| 2988 | { | 2988 | { |
| 2989 | font = font_open_by_name (f, names[i], strlen (names[i])); | 2989 | font = font_open_by_name (f, build_unibyte_string (names[i])); |
| 2990 | if (! NILP (font)) | 2990 | if (! NILP (font)) |
| 2991 | break; | 2991 | break; |
| 2992 | } | 2992 | } |