From 9dc774d4792633e32b3a2e583d6591faa721e637 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 17 Jun 2014 07:14:00 +0400 Subject: [PATCH] * fileio.c (Fread_file_name): Do not pass redundant args and ... * callint.c (read_file_name): ... convert to static here. * lisp.h (Fread_file_name): Do not EXFUN it. * composite.c (CHAR_COMPOSABLE_P): Replace unsafe macro with ... (char_composable_p): ... static function. All users changed. --- src/ChangeLog | 8 ++++++++ src/callint.c | 34 +++++++++++++++++++++++++--------- src/composite.c | 31 ++++++++++++++++--------------- src/fileio.c | 18 ------------------ src/lisp.h | 1 - 5 files changed, 49 insertions(+), 43 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c2f0d27fd73..142ede7d681 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2014-06-17 Dmitry Antipov + + * fileio.c (Fread_file_name): Do not pass redundant args and ... + * callint.c (read_file_name): ... convert to static here. + * lisp.h (Fread_file_name): Do not EXFUN it. + * composite.c (CHAR_COMPOSABLE_P): Replace unsafe macro with ... + (char_composable_p): ... static function. All users changed. + 2014-06-16 Paul Eggert * Makefile.in (ns-app): Fix typo that broke build on OS X. diff --git a/src/callint.c b/src/callint.c index 9e40cc01a62..b4dbc7efd2a 100644 --- a/src/callint.c +++ b/src/callint.c @@ -233,6 +233,26 @@ fix_command (Lisp_Object input, Lisp_Object values) } } +/* Helper function to call `read-file-name' from C. */ + +static Lisp_Object +read_file_name (Lisp_Object default_filename, Lisp_Object mustmatch, + Lisp_Object initial, Lisp_Object predicate) +{ + struct gcpro gcpro1; + Lisp_Object args[7]; + + GCPRO1 (default_filename); + args[0] = intern ("read-file-name"); + args[1] = callint_message; + args[2] = Qnil; + args[3] = default_filename; + args[4] = mustmatch; + args[5] = initial; + args[6] = predicate; + RETURN_UNGCPRO (Ffuncall (7, args)); +} + /* BEWARE: Calling this directly from C would defeat the purpose! */ DEFUN ("funcall-interactively", Ffuncall_interactively, Sfuncall_interactively, 1, MANY, 0, doc: /* Like `funcall' but marks the call as interactive. @@ -574,25 +594,21 @@ invoke it. If KEYS is omitted or nil, the return value of break; case 'D': /* Directory name. */ - args[i] = Fread_file_name (callint_message, Qnil, - BVAR (current_buffer, directory), Qlambda, Qnil, - Qfile_directory_p); + args[i] = read_file_name (BVAR (current_buffer, directory), Qlambda, Qnil, + Qfile_directory_p); break; case 'f': /* Existing file name. */ - args[i] = Fread_file_name (callint_message, - Qnil, Qnil, Qlambda, Qnil, Qnil); + args[i] = read_file_name (Qnil, Qlambda, Qnil, Qnil); break; case 'F': /* Possibly nonexistent file name. */ - args[i] = Fread_file_name (callint_message, - Qnil, Qnil, Qnil, Qnil, Qnil); + args[i] = read_file_name (Qnil, Qnil, Qnil, Qnil); break; case 'G': /* Possibly nonexistent file name, default to directory alone. */ - args[i] = Fread_file_name (callint_message, - Qnil, Qnil, Qnil, empty_unibyte_string, Qnil); + args[i] = read_file_name (Qnil, Qnil, empty_unibyte_string, Qnil); break; case 'i': /* Ignore an argument -- Does not do I/O. */ diff --git a/src/composite.c b/src/composite.c index fa882141908..5e14ad037a6 100644 --- a/src/composite.c +++ b/src/composite.c @@ -921,17 +921,18 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, return unbind_to (count, lgstring); } -static Lisp_Object _work_val; - /* 1 iff the character C is composable. Characters of general category Z? or C? are not composable except for ZWNJ and ZWJ. */ -#define CHAR_COMPOSABLE_P(C) \ - ((C) > ' ' \ - && ((C) == 0x200C || (C) == 0x200D \ - || (_work_val = CHAR_TABLE_REF (Vunicode_category_table, (C)), \ - (INTEGERP (_work_val) \ - && (XINT (_work_val) <= UNICODE_CATEGORY_So))))) +static bool +char_composable_p (int c) +{ + Lisp_Object val; + return (c > ' ' + && (c == 0x200C || c == 0x200D + || (val = CHAR_TABLE_REF (Vunicode_category_table, c), + (INTEGERP (val) && (XINT (val) <= UNICODE_CATEGORY_So))))); +} /* Update cmp_it->stop_pos to the next position after CHARPOS (and BYTEPOS) where character composition may happen. If BYTEPOS is @@ -1067,7 +1068,7 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos, p = SDATA (string) + bytepos; c = STRING_CHAR_AND_LENGTH (p, len); limit = bytepos + len; - while (CHAR_COMPOSABLE_P (c)) + while (char_composable_p (c)) { val = CHAR_TABLE_REF (Vcomposition_function_table, c); if (! NILP (val)) @@ -1144,7 +1145,7 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos, /* Skip all uncomposable characters. */ if (NILP (string)) { - while (charpos - 1 > endpos && ! CHAR_COMPOSABLE_P (c)) + while (charpos - 1 > endpos && ! char_composable_p (c)) { DEC_BOTH (charpos, bytepos); c = FETCH_MULTIBYTE_CHAR (bytepos); @@ -1152,7 +1153,7 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos, } else { - while (charpos - 1 > endpos && ! CHAR_COMPOSABLE_P (c)) + while (charpos - 1 > endpos && ! char_composable_p (c)) { p--; while (! CHAR_HEAD_P (*p)) @@ -1486,7 +1487,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, |-B-|-C-|--D--| Here, it is known that characters after positions 1 and 9 can - never be composed (i.e. ! CHAR_COMPOSABLE_P (CH)), and + never be composed (i.e. ! char_composable_p (CH)), and composition A is an invalid one because it's partially covered by the valid composition C. And to know whether a composition is valid or not, the only way is to start searching forward from a @@ -1510,7 +1511,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, while (1) { c = STRING_CHAR (cur.p); - if (! CHAR_COMPOSABLE_P (c)) + if (! char_composable_p (c)) { if (limit <= pos) /* case (1) */ { @@ -1519,7 +1520,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, return 0; BACKWARD_CHAR (cur, stop); c = STRING_CHAR (cur.p); - } while (! CHAR_COMPOSABLE_P (c)); + } while (! char_composable_p (c)); fore_check_limit = cur.pos + 1; } else /* case (2) */ @@ -1535,7 +1536,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, prev = cur; BACKWARD_CHAR (cur, stop); c = STRING_CHAR (cur.p); - if (! CHAR_COMPOSABLE_P (c)) + if (! char_composable_p (c)) { cur = prev; break; diff --git a/src/fileio.c b/src/fileio.c index dc3ed431d40..6fe11303ded 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -5762,24 +5762,6 @@ before any other event (mouse or keypress) is handled. */) return Qnil; } -Lisp_Object -Fread_file_name (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object initial, Lisp_Object predicate) -{ - struct gcpro gcpro1; - Lisp_Object args[7]; - - GCPRO1 (default_filename); - args[0] = intern ("read-file-name"); - args[1] = prompt; - args[2] = dir; - args[3] = default_filename; - args[4] = mustmatch; - args[5] = initial; - args[6] = predicate; - RETURN_UNGCPRO (Ffuncall (7, args)); -} - - void init_fileio (void) { diff --git a/src/lisp.h b/src/lisp.h index 280886d063a..e28a415152b 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4015,7 +4015,6 @@ extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object); extern Lisp_Object write_region (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, int); -EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */ extern void close_file_unwind (int); extern void fclose_unwind (void *); extern void restore_point_unwind (Lisp_Object); -- 2.39.2