Mercurial > hg > xemacs-beta
comparison src/casefiddle.c @ 4910:6bc1f3f6cf0d
Make canoncase visible to Lisp; use it with chars in internal_equalp.
src/ChangeLog addition:
2010-02-01 Aidan Kehoe <kehoea@parhasard.net>
* fns.c (internal_equalp):
Use bytecode_arithcompare, which takes two args, instead of
passing a stack pointer to Feqlsign.
Use CANONCASE(), not DOWNCASE(), for case-insensitive character
comparison.
Correct a comment here.
* casefiddle.c (casify_object): New operation in this function,
CASE_CANONICALIZE.
(Fcanoncase): New function, used for case-insensitive comparison.
* lisp.h:
Make Fcanoncase, bytecode_arithcompare visible here.
* bytecode.c (bytecode_arithcompare):
Make this visible to other files.
lisp/ChangeLog addition:
2010-02-01 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (equalp):
Remove special treatment for an #'equalp with a single character
constant argument, it was incorrect (it used #'downcase instead of
#'canoncase).
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 01 Feb 2010 17:57:04 +0000 |
parents | ecf1ebac70d8 |
children | 308d34e9f07d |
comparison
equal
deleted
inserted
replaced
4909:87175eb65ff4 | 4910:6bc1f3f6cf0d |
---|---|
26 | 26 |
27 #include "buffer.h" | 27 #include "buffer.h" |
28 #include "insdel.h" | 28 #include "insdel.h" |
29 #include "syntax.h" | 29 #include "syntax.h" |
30 | 30 |
31 enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP}; | 31 enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP, |
32 CASE_CANONICALIZE}; | |
32 | 33 |
33 static Lisp_Object | 34 static Lisp_Object |
34 casify_object (enum case_action flag, Lisp_Object string_or_char, | 35 casify_object (enum case_action flag, Lisp_Object string_or_char, |
35 Lisp_Object buffer) | 36 Lisp_Object buffer) |
36 { | 37 { |
41 if (CHAR_OR_CHAR_INTP (string_or_char)) | 42 if (CHAR_OR_CHAR_INTP (string_or_char)) |
42 { | 43 { |
43 Ichar c; | 44 Ichar c; |
44 CHECK_CHAR_COERCE_INT (string_or_char); | 45 CHECK_CHAR_COERCE_INT (string_or_char); |
45 c = XCHAR (string_or_char); | 46 c = XCHAR (string_or_char); |
46 c = (flag == CASE_DOWN) ? DOWNCASE (buf, c) : UPCASE (buf, c); | 47 if (flag == CASE_DOWN) |
48 { | |
49 c = DOWNCASE (buf, c); | |
50 } | |
51 else if (flag == CASE_UP) | |
52 { | |
53 c = UPCASE (buf, c); | |
54 } | |
55 else | |
56 { | |
57 c = CANONCASE (buf, c); | |
58 } | |
59 | |
47 return make_char (c); | 60 return make_char (c); |
48 } | 61 } |
49 | 62 |
50 if (STRINGP (string_or_char)) | 63 if (STRINGP (string_or_char)) |
51 { | 64 { |
65 case CASE_UP: | 78 case CASE_UP: |
66 c = UPCASE (buf, c); | 79 c = UPCASE (buf, c); |
67 break; | 80 break; |
68 case CASE_DOWN: | 81 case CASE_DOWN: |
69 c = DOWNCASE (buf, c); | 82 c = DOWNCASE (buf, c); |
83 break; | |
84 case CASE_CANONICALIZE: | |
85 c = CANONCASE (buf, c); | |
70 break; | 86 break; |
71 case CASE_CAPITALIZE: | 87 case CASE_CAPITALIZE: |
72 case CASE_CAPITALIZE_UP: | 88 case CASE_CAPITALIZE_UP: |
73 wordp_prev = wordp; | 89 wordp_prev = wordp; |
74 wordp = WORD_SYNTAX_P (syntax_table, c); | 90 wordp = WORD_SYNTAX_P (syntax_table, c); |
115 and defaults to the current buffer. | 131 and defaults to the current buffer. |
116 */ | 132 */ |
117 (string_or_char, buffer)) | 133 (string_or_char, buffer)) |
118 { | 134 { |
119 return casify_object (CASE_DOWN, string_or_char, buffer); | 135 return casify_object (CASE_DOWN, string_or_char, buffer); |
136 } | |
137 | |
138 DEFUN ("canoncase", Fcanoncase, 1, 2, 0, /* | |
139 Convert STRING-OR-CHAR to its canonical lowercase form and return that. | |
140 | |
141 STRING-OR-CHAR may be a character or string. The result has the same type. | |
142 STRING-OR-CHAR is not altered--the value is a copy. | |
143 | |
144 Optional second arg BUFFER specifies which buffer's case tables to use, | |
145 and defaults to the current buffer. | |
146 | |
147 For any N characters that are equivalent in case-insensitive searching, | |
148 their canonical lowercase character will be the same. | |
149 */ | |
150 (string_or_char, buffer)) | |
151 { | |
152 return casify_object (CASE_CANONICALIZE, string_or_char, buffer); | |
120 } | 153 } |
121 | 154 |
122 DEFUN ("capitalize", Fcapitalize, 1, 2, 0, /* | 155 DEFUN ("capitalize", Fcapitalize, 1, 2, 0, /* |
123 Convert STRING-OR-CHAR to capitalized form and return that. | 156 Convert STRING-OR-CHAR to capitalized form and return that. |
124 This means that each word's first character is upper case | 157 This means that each word's first character is upper case |
329 void | 362 void |
330 syms_of_casefiddle (void) | 363 syms_of_casefiddle (void) |
331 { | 364 { |
332 DEFSUBR (Fupcase); | 365 DEFSUBR (Fupcase); |
333 DEFSUBR (Fdowncase); | 366 DEFSUBR (Fdowncase); |
367 DEFSUBR (Fcanoncase); | |
334 DEFSUBR (Fcapitalize); | 368 DEFSUBR (Fcapitalize); |
335 DEFSUBR (Fupcase_initials); | 369 DEFSUBR (Fupcase_initials); |
336 DEFSUBR (Fupcase_region); | 370 DEFSUBR (Fupcase_region); |
337 DEFSUBR (Fdowncase_region); | 371 DEFSUBR (Fdowncase_region); |
338 DEFSUBR (Fcapitalize_region); | 372 DEFSUBR (Fcapitalize_region); |