aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-06-17 07:14:00 +0400
committerDmitry Antipov2014-06-17 07:14:00 +0400
commit9dc774d4792633e32b3a2e583d6591faa721e637 (patch)
tree374dc5f254d18ec80eba68cefd8ecdaa43d89597 /src
parent64e104891f14070bccd1bae0b6da8f2d7091a3f1 (diff)
downloademacs-9dc774d4792633e32b3a2e583d6591faa721e637.tar.gz
emacs-9dc774d4792633e32b3a2e583d6591faa721e637.zip
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/callint.c34
-rw-r--r--src/composite.c31
-rw-r--r--src/fileio.c18
-rw-r--r--src/lisp.h1
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 @@
12014-06-17 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * fileio.c (Fread_file_name): Do not pass redundant args and ...
4 * callint.c (read_file_name): ... convert to static here.
5 * lisp.h (Fread_file_name): Do not EXFUN it.
6 * composite.c (CHAR_COMPOSABLE_P): Replace unsafe macro with ...
7 (char_composable_p): ... static function. All users changed.
8
12014-06-16 Paul Eggert <eggert@cs.ucla.edu> 92014-06-16 Paul Eggert <eggert@cs.ucla.edu>
2 10
3 * Makefile.in (ns-app): Fix typo that broke build on OS X. 11 * 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)
233 } 233 }
234} 234}
235 235
236/* Helper function to call `read-file-name' from C. */
237
238static Lisp_Object
239read_file_name (Lisp_Object default_filename, Lisp_Object mustmatch,
240 Lisp_Object initial, Lisp_Object predicate)
241{
242 struct gcpro gcpro1;
243 Lisp_Object args[7];
244
245 GCPRO1 (default_filename);
246 args[0] = intern ("read-file-name");
247 args[1] = callint_message;
248 args[2] = Qnil;
249 args[3] = default_filename;
250 args[4] = mustmatch;
251 args[5] = initial;
252 args[6] = predicate;
253 RETURN_UNGCPRO (Ffuncall (7, args));
254}
255
236/* BEWARE: Calling this directly from C would defeat the purpose! */ 256/* BEWARE: Calling this directly from C would defeat the purpose! */
237DEFUN ("funcall-interactively", Ffuncall_interactively, Sfuncall_interactively, 257DEFUN ("funcall-interactively", Ffuncall_interactively, Sfuncall_interactively,
238 1, MANY, 0, doc: /* Like `funcall' but marks the call as interactive. 258 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
574 break; 594 break;
575 595
576 case 'D': /* Directory name. */ 596 case 'D': /* Directory name. */
577 args[i] = Fread_file_name (callint_message, Qnil, 597 args[i] = read_file_name (BVAR (current_buffer, directory), Qlambda, Qnil,
578 BVAR (current_buffer, directory), Qlambda, Qnil, 598 Qfile_directory_p);
579 Qfile_directory_p);
580 break; 599 break;
581 600
582 case 'f': /* Existing file name. */ 601 case 'f': /* Existing file name. */
583 args[i] = Fread_file_name (callint_message, 602 args[i] = read_file_name (Qnil, Qlambda, Qnil, Qnil);
584 Qnil, Qnil, Qlambda, Qnil, Qnil);
585 break; 603 break;
586 604
587 case 'F': /* Possibly nonexistent file name. */ 605 case 'F': /* Possibly nonexistent file name. */
588 args[i] = Fread_file_name (callint_message, 606 args[i] = read_file_name (Qnil, Qnil, Qnil, Qnil);
589 Qnil, Qnil, Qnil, Qnil, Qnil);
590 break; 607 break;
591 608
592 case 'G': /* Possibly nonexistent file name, 609 case 'G': /* Possibly nonexistent file name,
593 default to directory alone. */ 610 default to directory alone. */
594 args[i] = Fread_file_name (callint_message, 611 args[i] = read_file_name (Qnil, Qnil, empty_unibyte_string, Qnil);
595 Qnil, Qnil, Qnil, empty_unibyte_string, Qnil);
596 break; 612 break;
597 613
598 case 'i': /* Ignore an argument -- Does not do I/O. */ 614 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,
921 return unbind_to (count, lgstring); 921 return unbind_to (count, lgstring);
922} 922}
923 923
924static Lisp_Object _work_val;
925
926/* 1 iff the character C is composable. Characters of general 924/* 1 iff the character C is composable. Characters of general
927 category Z? or C? are not composable except for ZWNJ and ZWJ. */ 925 category Z? or C? are not composable except for ZWNJ and ZWJ. */
928 926
929#define CHAR_COMPOSABLE_P(C) \ 927static bool
930 ((C) > ' ' \ 928char_composable_p (int c)
931 && ((C) == 0x200C || (C) == 0x200D \ 929{
932 || (_work_val = CHAR_TABLE_REF (Vunicode_category_table, (C)), \ 930 Lisp_Object val;
933 (INTEGERP (_work_val) \ 931 return (c > ' '
934 && (XINT (_work_val) <= UNICODE_CATEGORY_So))))) 932 && (c == 0x200C || c == 0x200D
933 || (val = CHAR_TABLE_REF (Vunicode_category_table, c),
934 (INTEGERP (val) && (XINT (val) <= UNICODE_CATEGORY_So)))));
935}
935 936
936/* Update cmp_it->stop_pos to the next position after CHARPOS (and 937/* Update cmp_it->stop_pos to the next position after CHARPOS (and
937 BYTEPOS) where character composition may happen. If BYTEPOS is 938 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,
1067 p = SDATA (string) + bytepos; 1068 p = SDATA (string) + bytepos;
1068 c = STRING_CHAR_AND_LENGTH (p, len); 1069 c = STRING_CHAR_AND_LENGTH (p, len);
1069 limit = bytepos + len; 1070 limit = bytepos + len;
1070 while (CHAR_COMPOSABLE_P (c)) 1071 while (char_composable_p (c))
1071 { 1072 {
1072 val = CHAR_TABLE_REF (Vcomposition_function_table, c); 1073 val = CHAR_TABLE_REF (Vcomposition_function_table, c);
1073 if (! NILP (val)) 1074 if (! NILP (val))
@@ -1144,7 +1145,7 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos,
1144 /* Skip all uncomposable characters. */ 1145 /* Skip all uncomposable characters. */
1145 if (NILP (string)) 1146 if (NILP (string))
1146 { 1147 {
1147 while (charpos - 1 > endpos && ! CHAR_COMPOSABLE_P (c)) 1148 while (charpos - 1 > endpos && ! char_composable_p (c))
1148 { 1149 {
1149 DEC_BOTH (charpos, bytepos); 1150 DEC_BOTH (charpos, bytepos);
1150 c = FETCH_MULTIBYTE_CHAR (bytepos); 1151 c = FETCH_MULTIBYTE_CHAR (bytepos);
@@ -1152,7 +1153,7 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos,
1152 } 1153 }
1153 else 1154 else
1154 { 1155 {
1155 while (charpos - 1 > endpos && ! CHAR_COMPOSABLE_P (c)) 1156 while (charpos - 1 > endpos && ! char_composable_p (c))
1156 { 1157 {
1157 p--; 1158 p--;
1158 while (! CHAR_HEAD_P (*p)) 1159 while (! CHAR_HEAD_P (*p))
@@ -1486,7 +1487,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit,
1486 |-B-|-C-|--D--| 1487 |-B-|-C-|--D--|
1487 1488
1488 Here, it is known that characters after positions 1 and 9 can 1489 Here, it is known that characters after positions 1 and 9 can
1489 never be composed (i.e. ! CHAR_COMPOSABLE_P (CH)), and 1490 never be composed (i.e. ! char_composable_p (CH)), and
1490 composition A is an invalid one because it's partially covered by 1491 composition A is an invalid one because it's partially covered by
1491 the valid composition C. And to know whether a composition is 1492 the valid composition C. And to know whether a composition is
1492 valid or not, the only way is to start searching forward from a 1493 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,
1510 while (1) 1511 while (1)
1511 { 1512 {
1512 c = STRING_CHAR (cur.p); 1513 c = STRING_CHAR (cur.p);
1513 if (! CHAR_COMPOSABLE_P (c)) 1514 if (! char_composable_p (c))
1514 { 1515 {
1515 if (limit <= pos) /* case (1) */ 1516 if (limit <= pos) /* case (1) */
1516 { 1517 {
@@ -1519,7 +1520,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit,
1519 return 0; 1520 return 0;
1520 BACKWARD_CHAR (cur, stop); 1521 BACKWARD_CHAR (cur, stop);
1521 c = STRING_CHAR (cur.p); 1522 c = STRING_CHAR (cur.p);
1522 } while (! CHAR_COMPOSABLE_P (c)); 1523 } while (! char_composable_p (c));
1523 fore_check_limit = cur.pos + 1; 1524 fore_check_limit = cur.pos + 1;
1524 } 1525 }
1525 else /* case (2) */ 1526 else /* case (2) */
@@ -1535,7 +1536,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit,
1535 prev = cur; 1536 prev = cur;
1536 BACKWARD_CHAR (cur, stop); 1537 BACKWARD_CHAR (cur, stop);
1537 c = STRING_CHAR (cur.p); 1538 c = STRING_CHAR (cur.p);
1538 if (! CHAR_COMPOSABLE_P (c)) 1539 if (! char_composable_p (c))
1539 { 1540 {
1540 cur = prev; 1541 cur = prev;
1541 break; 1542 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. */)
5762 return Qnil; 5762 return Qnil;
5763} 5763}
5764 5764
5765Lisp_Object
5766Fread_file_name (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object initial, Lisp_Object predicate)
5767{
5768 struct gcpro gcpro1;
5769 Lisp_Object args[7];
5770
5771 GCPRO1 (default_filename);
5772 args[0] = intern ("read-file-name");
5773 args[1] = prompt;
5774 args[2] = dir;
5775 args[3] = default_filename;
5776 args[4] = mustmatch;
5777 args[5] = initial;
5778 args[6] = predicate;
5779 RETURN_UNGCPRO (Ffuncall (7, args));
5780}
5781
5782
5783void 5765void
5784init_fileio (void) 5766init_fileio (void)
5785{ 5767{
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);
4015extern Lisp_Object write_region (Lisp_Object, Lisp_Object, Lisp_Object, 4015extern Lisp_Object write_region (Lisp_Object, Lisp_Object, Lisp_Object,
4016 Lisp_Object, Lisp_Object, Lisp_Object, 4016 Lisp_Object, Lisp_Object, Lisp_Object,
4017 Lisp_Object, int); 4017 Lisp_Object, int);
4018EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */
4019extern void close_file_unwind (int); 4018extern void close_file_unwind (int);
4020extern void fclose_unwind (void *); 4019extern void fclose_unwind (void *);
4021extern void restore_point_unwind (Lisp_Object); 4020extern void restore_point_unwind (Lisp_Object);