Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- a/src/casefiddle.c Mon Feb 01 06:20:05 2010 -0600 +++ b/src/casefiddle.c Mon Feb 01 17:57:04 2010 +0000 @@ -28,7 +28,8 @@ #include "insdel.h" #include "syntax.h" -enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP}; +enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP, + CASE_CANONICALIZE}; static Lisp_Object casify_object (enum case_action flag, Lisp_Object string_or_char, @@ -43,7 +44,19 @@ Ichar c; CHECK_CHAR_COERCE_INT (string_or_char); c = XCHAR (string_or_char); - c = (flag == CASE_DOWN) ? DOWNCASE (buf, c) : UPCASE (buf, c); + if (flag == CASE_DOWN) + { + c = DOWNCASE (buf, c); + } + else if (flag == CASE_UP) + { + c = UPCASE (buf, c); + } + else + { + c = CANONCASE (buf, c); + } + return make_char (c); } @@ -68,6 +81,9 @@ case CASE_DOWN: c = DOWNCASE (buf, c); break; + case CASE_CANONICALIZE: + c = CANONCASE (buf, c); + break; case CASE_CAPITALIZE: case CASE_CAPITALIZE_UP: wordp_prev = wordp; @@ -119,6 +135,23 @@ return casify_object (CASE_DOWN, string_or_char, buffer); } +DEFUN ("canoncase", Fcanoncase, 1, 2, 0, /* +Convert STRING-OR-CHAR to its canonical lowercase form and return that. + +STRING-OR-CHAR may be a character or string. The result has the same type. +STRING-OR-CHAR is not altered--the value is a copy. + +Optional second arg BUFFER specifies which buffer's case tables to use, +and defaults to the current buffer. + +For any N characters that are equivalent in case-insensitive searching, +their canonical lowercase character will be the same. +*/ + (string_or_char, buffer)) +{ + return casify_object (CASE_CANONICALIZE, string_or_char, buffer); +} + DEFUN ("capitalize", Fcapitalize, 1, 2, 0, /* Convert STRING-OR-CHAR to capitalized form and return that. This means that each word's first character is upper case @@ -331,6 +364,7 @@ { DEFSUBR (Fupcase); DEFSUBR (Fdowncase); + DEFSUBR (Fcanoncase); DEFSUBR (Fcapitalize); DEFSUBR (Fupcase_initials); DEFSUBR (Fupcase_region);