X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/2f241ea5576dd3c6ad54b8c14828c8e934fa34a9..2989ad906048b374653d7030ebdaea62b670eed0:/src/casetab.c diff --git a/src/casetab.c b/src/casetab.c index 64e47859d9..2461647bb1 100644 --- a/src/casetab.c +++ b/src/casetab.c @@ -1,5 +1,5 @@ /* GNU Emacs routines to deal with case tables. - Copyright (C) 1993-1994, 2001-2011 Free Software Foundation, Inc. + Copyright (C) 1993-1994, 2001-2016 Free Software Foundation, Inc. Author: Howard Gayle @@ -7,8 +7,8 @@ This file is part of GNU Emacs. GNU Emacs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +the Free Software Foundation, either version 3 of the License, or (at +your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,12 +19,10 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ #include -#include + #include "lisp.h" #include "buffer.h" -#include "character.h" -static Lisp_Object Qcase_table_p, Qcase_table; Lisp_Object Vascii_downcase_table; static Lisp_Object Vascii_upcase_table; Lisp_Object Vascii_canon_table; @@ -79,7 +77,7 @@ This is the one used for new buffers. */) return Vascii_downcase_table; } -static Lisp_Object set_case_table (Lisp_Object table, int standard); +static Lisp_Object set_case_table (Lisp_Object, bool); DEFUN ("set-case-table", Fset_case_table, Sset_case_table, 1, 1, 0, doc: /* Select a new case table for the current buffer. @@ -95,7 +93,7 @@ CANONICALIZE maps each character to a canonical equivalent; any two characters that are related by case-conversion have the same canonical equivalent character; it may be nil, in which case it is deduced from DOWNCASE and UPCASE. -EQUIVALENCES is a map that cyclicly permutes each equivalence class +EQUIVALENCES is a map that cyclically permutes each equivalence class (of characters with the same canonical equivalent); it may be nil, in which case it is deduced from CANONICALIZE. */) (Lisp_Object table) @@ -113,7 +111,7 @@ See `set-case-table' for more info on case tables. */) } static Lisp_Object -set_case_table (Lisp_Object table, int standard) +set_case_table (Lisp_Object table, bool standard) { Lisp_Object up, canon, eqv; @@ -128,13 +126,13 @@ set_case_table (Lisp_Object table, int standard) up = Fmake_char_table (Qcase_table, Qnil); map_char_table (set_identity, Qnil, table, up); map_char_table (shuffle, Qnil, table, up); - XCHAR_TABLE (table)->extras[0] = up; + set_char_table_extras (table, 0, up); } if (NILP (canon)) { canon = Fmake_char_table (Qcase_table, Qnil); - XCHAR_TABLE (table)->extras[1] = canon; + set_char_table_extras (table, 1, canon); map_char_table (set_canon, Qnil, table, table); } @@ -143,11 +141,11 @@ set_case_table (Lisp_Object table, int standard) eqv = Fmake_char_table (Qcase_table, Qnil); map_char_table (set_identity, Qnil, canon, eqv); map_char_table (shuffle, Qnil, canon, eqv); - XCHAR_TABLE (table)->extras[2] = eqv; + set_char_table_extras (table, 2, eqv); } /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (canon)->extras[2] = eqv; + set_char_table_extras (canon, 2, eqv); if (standard) { @@ -158,10 +156,10 @@ set_case_table (Lisp_Object table, int standard) } else { - 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; + bset_downcase_table (current_buffer, table); + bset_upcase_table (current_buffer, up); + bset_case_canon_table (current_buffer, canon); + bset_case_eqv_table (current_buffer, eqv); } return table; @@ -205,7 +203,6 @@ set_identity (Lisp_Object table, Lisp_Object c, Lisp_Object elt) from = to = XINT (c); to++; - lint_assume (to <= MAX_CHAR + 1); for (; from < to; from++) CHAR_TABLE_SET (table, from, make_number (from)); } @@ -232,7 +229,6 @@ shuffle (Lisp_Object table, Lisp_Object c, Lisp_Object elt) from = to = XINT (c); to++; - lint_assume (to <= MAX_CHAR + 1); for (; from < to; from++) { Lisp_Object tem = Faref (table, elt); @@ -246,21 +242,14 @@ void init_casetab_once (void) { register int i; - Lisp_Object down, up; - DEFSYM (Qcase_table, "case-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_c_string ("char-table-extra-slots"); + Lisp_Object down, up, eqv; - /* Now we are ready to set up this property, so we can - create char tables. */ + DEFSYM (Qcase_table, "case-table"); Fput (Qcase_table, Qchar_table_extra_slots, make_number (3)); down = Fmake_char_table (Qcase_table, Qnil); Vascii_downcase_table = down; - XCHAR_TABLE (down)->purpose = Qcase_table; + set_char_table_purpose (down, Qcase_table); for (i = 0; i < 128; i++) { @@ -268,20 +257,28 @@ init_casetab_once (void) CHAR_TABLE_SET (down, i, make_number (c)); } - XCHAR_TABLE (down)->extras[1] = Fcopy_sequence (down); + set_char_table_extras (down, 1, Fcopy_sequence (down)); up = Fmake_char_table (Qcase_table, Qnil); - XCHAR_TABLE (down)->extras[0] = up; + set_char_table_extras (down, 0, up); for (i = 0; i < 128; i++) { + int c = (i >= 'a' && i <= 'z') ? i + ('A' - 'a') : i; + CHAR_TABLE_SET (up, i, make_number (c)); + } + + eqv = Fmake_char_table (Qcase_table, Qnil); + + for (i = 0; i < 128; i++) + { int c = ((i >= 'A' && i <= 'Z') ? i + ('a' - 'A') : ((i >= 'a' && i <= 'z') ? i + ('A' - 'a') : i)); - CHAR_TABLE_SET (up, i, make_number (c)); + CHAR_TABLE_SET (eqv, i, make_number (c)); } - XCHAR_TABLE (down)->extras[2] = Fcopy_sequence (up); + set_char_table_extras (down, 2, eqv); /* Fill in what isn't filled in. */ set_case_table (down, 1);