X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/b35f288d478ef137a4d9e8e5a6a5f368a86b01f5..d2fc7e3d0f6f57f962cbd94df3bf4fd15a37bb68:/src/casetab.c diff --git a/src/casetab.c b/src/casetab.c index d2056002dd..29120dd08c 100644 --- a/src/casetab.c +++ b/src/casetab.c @@ -1,6 +1,7 @@ /* GNU Emacs routines to deal with case tables. - Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1993-1994, 2001-2011 Free Software Foundation, Inc. + +Author: Howard Gayle This file is part of GNU Emacs. @@ -17,31 +18,26 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ -/* Written by Howard Gayle. */ - #include +#include #include "lisp.h" #include "buffer.h" #include "character.h" -Lisp_Object Qcase_table_p, Qcase_table; -Lisp_Object Vascii_downcase_table, Vascii_upcase_table; -Lisp_Object Vascii_canon_table, Vascii_eqv_table; - -/* Used as a temporary in DOWNCASE and other macros in lisp.h. No - need to mark it, since it is used only very temporarily. */ -int case_temp1; -Lisp_Object case_temp2; +static Lisp_Object Qcase_table_p, Qcase_table; +Lisp_Object Vascii_downcase_table; +static Lisp_Object Vascii_upcase_table; +Lisp_Object Vascii_canon_table; +static Lisp_Object Vascii_eqv_table; -static void set_canon (); -static void set_identity (); -static void shuffle (); +static void set_canon (Lisp_Object case_table, Lisp_Object range, Lisp_Object elt); +static void set_identity (Lisp_Object table, Lisp_Object c, Lisp_Object elt); +static void shuffle (Lisp_Object table, Lisp_Object c, Lisp_Object elt); DEFUN ("case-table-p", Fcase_table_p, Scase_table_p, 1, 1, 0, doc: /* Return t if OBJECT is a case table. See `set-case-table' for more information on these data structures. */) - (object) - Lisp_Object object; + (Lisp_Object object) { Lisp_Object up, canon, eqv; @@ -62,8 +58,7 @@ See `set-case-table' for more information on these data structures. */) } static Lisp_Object -check_case_table (obj) - Lisp_Object obj; +check_case_table (Lisp_Object obj) { CHECK_TYPE (!NILP (Fcase_table_p (obj)), Qcase_table_p, obj); return (obj); @@ -71,20 +66,20 @@ check_case_table (obj) DEFUN ("current-case-table", Fcurrent_case_table, Scurrent_case_table, 0, 0, 0, doc: /* Return the case table of the current buffer. */) - () + (void) { - return current_buffer->downcase_table; + return BVAR (current_buffer, downcase_table); } DEFUN ("standard-case-table", Fstandard_case_table, Sstandard_case_table, 0, 0, 0, doc: /* Return the standard case table. This is the one used for new buffers. */) - () + (void) { return Vascii_downcase_table; } -static Lisp_Object set_case_table (); +static Lisp_Object set_case_table (Lisp_Object table, int standard); DEFUN ("set-case-table", Fset_case_table, Sset_case_table, 1, 1, 0, doc: /* Select a new case table for the current buffer. @@ -103,25 +98,22 @@ CANONICALIZE maps each character to a canonical equivalent; EQUIVALENCES is a map that cyclicly permutes each equivalence class (of characters with the same canonical equivalent); it may be nil, in which case it is deduced from CANONICALIZE. */) - (table) - Lisp_Object table; + (Lisp_Object table) { return set_case_table (table, 0); } -DEFUN ("set-standard-case-table", Fset_standard_case_table, Sset_standard_case_table, 1, 1, 0, +DEFUN ("set-standard-case-table", Fset_standard_case_table, + Sset_standard_case_table, 1, 1, 0, doc: /* Select a new standard case table for new buffers. See `set-case-table' for more info on case tables. */) - (table) - Lisp_Object table; + (Lisp_Object table) { return set_case_table (table, 1); } static Lisp_Object -set_case_table (table, standard) - Lisp_Object table; - int standard; +set_case_table (Lisp_Object table, int standard) { Lisp_Object up, canon, eqv; @@ -166,10 +158,10 @@ set_case_table (table, standard) } else { - current_buffer->downcase_table = table; - current_buffer->upcase_table = up; - current_buffer->case_canon_table = canon; - current_buffer->case_eqv_table = eqv; + BVAR (current_buffer, downcase_table) = table; + BVAR (current_buffer, upcase_table) = up; + BVAR (current_buffer, case_canon_table) = canon; + BVAR (current_buffer, case_eqv_table) = eqv; } return table; @@ -183,8 +175,7 @@ set_case_table (table, standard) CASE_TABLE. */ static void -set_canon (case_table, range, elt) - Lisp_Object case_table, range, elt; +set_canon (Lisp_Object case_table, Lisp_Object range, Lisp_Object elt) { Lisp_Object up = XCHAR_TABLE (case_table)->extras[0]; Lisp_Object canon = XCHAR_TABLE (case_table)->extras[1]; @@ -199,12 +190,12 @@ set_canon (case_table, range, elt) character. This is called in map_char_table. */ static void -set_identity (table, c, elt) - Lisp_Object table, c, elt; +set_identity (Lisp_Object table, Lisp_Object c, Lisp_Object elt) { if (NATNUMP (elt)) { - int from, to; + int from; + unsigned to; if (CONSP (c)) { @@ -213,7 +204,7 @@ set_identity (table, c, elt) } else from = to = XINT (c); - for (; from <= to; from++) + for (to++; from < to; from++) CHAR_TABLE_SET (table, from, make_number (from)); } } @@ -224,13 +215,12 @@ set_identity (table, c, elt) operated. */ static void -shuffle (table, c, elt) - Lisp_Object table, c, elt; +shuffle (Lisp_Object table, Lisp_Object c, Lisp_Object elt) { if (NATNUMP (elt)) { - Lisp_Object tem = Faref (table, elt); - int from, to; + int from; + unsigned to; if (CONSP (c)) { @@ -240,27 +230,27 @@ shuffle (table, c, elt) else from = to = XINT (c); - for (; from <= to; from++) - if (from != XINT (elt)) - { - Faset (table, elt, make_number (from)); - Faset (table, make_number (from), tem); - } + for (to++; from < to; from++) + { + Lisp_Object tem = Faref (table, elt); + Faset (table, elt, make_number (from)); + Faset (table, make_number (from), tem); + } } } void -init_casetab_once () +init_casetab_once (void) { register int i; Lisp_Object down, up; - Qcase_table = intern ("case-table"); + Qcase_table = intern_c_string ("case-table"); staticpro (&Qcase_table); /* Intern this now in case it isn't already done. Setting this variable twice is harmless. But don't staticpro it here--that is done in alloc.c. */ - Qchar_table_extra_slots = intern ("char-table-extra-slots"); + Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots"); /* Now we are ready to set up this property, so we can create char tables. */ @@ -285,7 +275,7 @@ init_casetab_once () { int c = ((i >= 'A' && i <= 'Z') ? i + ('a' - 'A') : ((i >= 'a' && i <= 'z') ? i + ('A' - 'a') - : i));; + : i)); CHAR_TABLE_SET (up, i, make_number (c)); } @@ -296,9 +286,9 @@ init_casetab_once () } void -syms_of_casetab () +syms_of_casetab (void) { - Qcase_table_p = intern ("case-table-p"); + Qcase_table_p = intern_c_string ("case-table-p"); staticpro (&Qcase_table_p); staticpro (&Vascii_canon_table); @@ -312,6 +302,3 @@ syms_of_casetab () defsubr (&Sset_case_table); defsubr (&Sset_standard_case_table); } - -/* arch-tag: e06388ad-99fe-40ec-ba67-9d010fcc4916 - (do not change this comment) */