]> code.delx.au - gnu-emacs/blobdiff - src/category.c
Fix port to glibc 2.24 (pre-release) + ppc64
[gnu-emacs] / src / category.c
index 30ffbd0890f11ad9c1817f17119a71199aab2e17..4397f662ba9ebe42a8deb6c51bee0246852c66ee 100644 (file)
@@ -1,6 +1,6 @@
 /* GNU Emacs routines to deal with category tables.
 
-Copyright (C) 1998, 2001-2013 Free Software Foundation, Inc.
+Copyright (C) 1998, 2001-2016 Free Software Foundation, Inc.
 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
   2005, 2006, 2007, 2008, 2009, 2010, 2011
   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -13,8 +13,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
@@ -30,20 +30,16 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
-#define CATEGORY_INLINE EXTERN_INLINE
-
 #include "lisp.h"
 #include "character.h"
 #include "buffer.h"
-#include "charset.h"
 #include "category.h"
-#include "keymap.h"
 
 /* This setter is used only in this file, so it can be private.  */
 static void
 bset_category_table (struct buffer *b, Lisp_Object val)
 {
-  b->INTERNAL_FIELD (category_table) = val;
+  b->category_table_ = val;
 }
 
 /* The version number of the latest category table.  Each category
@@ -55,19 +51,9 @@ bset_category_table (struct buffer *b, Lisp_Object val)
 
    For the moment, we are not using this feature.  */
 static int category_table_version;
-
-static Lisp_Object Qcategory_table, Qcategoryp, Qcategorysetp, Qcategory_table_p;
-
-/* Make CATEGORY_SET includes (if VAL is t) or excludes (if VAL is
-   nil) CATEGORY.  */
-#define SET_CATEGORY_SET(category_set, category, val) \
-  set_category_set (category_set, category, val)
-static void set_category_set (Lisp_Object, Lisp_Object, Lisp_Object);
 \f
 /* Category set staff.  */
 
-static Lisp_Object hash_get_category_set (Lisp_Object, Lisp_Object);
-
 static Lisp_Object
 hash_get_category_set (Lisp_Object table, Lisp_Object category_set)
 {
@@ -90,6 +76,13 @@ hash_get_category_set (Lisp_Object table, Lisp_Object category_set)
   return category_set;
 }
 
+/* Make CATEGORY_SET include (if VAL) or exclude (if !VAL) CATEGORY.  */
+
+static void
+set_category_set (Lisp_Object category_set, EMACS_INT category, bool val)
+{
+  bool_vector_set (category_set, category, val);
+}
 
 DEFUN ("make-category-set", Fmake_category_set, Smake_category_set, 1, 1, 0,
        doc: /* Return a newly created category-set which contains CATEGORIES.
@@ -99,7 +92,7 @@ those categories.  */)
   (Lisp_Object categories)
 {
   Lisp_Object val;
-  int len;
+  ptrdiff_t len;
 
   CHECK_STRING (categories);
   val = MAKE_CATEGORY_SET;
@@ -110,11 +103,11 @@ those categories.  */)
   len = SCHARS (categories);
   while (--len >= 0)
     {
-      Lisp_Object category;
+      unsigned char cat = SREF (categories, len);
+      Lisp_Object category = make_number (cat);
 
-      XSETFASTINT (category, SREF (categories, len));
       CHECK_CATEGORY (category);
-      SET_CATEGORY_SET (val, category, Qt);
+      set_category_set (val, cat, 1);
     }
   return val;
 }
@@ -336,20 +329,6 @@ The return value is a string containing those same categories.  */)
   return build_string (str);
 }
 
-static void
-set_category_set (Lisp_Object category_set, Lisp_Object category, Lisp_Object val)
-{
-  do {
-    int idx = XINT (category) / 8;
-    unsigned char bits = 1 << (XINT (category) % 8);
-
-    if (NILP (val))
-      XCATEGORY_SET (category_set)->data[idx] &= ~bits;
-    else
-      XCATEGORY_SET (category_set)->data[idx] |= bits;
-  } while (0);
-}
-
 DEFUN ("modify-category-entry", Fmodify_category_entry,
        Smodify_category_entry, 2, 4, 0,
        doc: /* Modify the category set of CHARACTER by adding CATEGORY to it.
@@ -361,7 +340,7 @@ If optional fourth argument RESET is non-nil,
 then delete CATEGORY from the category set instead of adding it.  */)
   (Lisp_Object character, Lisp_Object category, Lisp_Object table, Lisp_Object reset)
 {
-  Lisp_Object set_value;       /* Actual value to be set in category sets.  */
+  bool set_value;      /* Actual value to be set in category sets.  */
   Lisp_Object category_set;
   int start, end;
   int from, to;
@@ -386,7 +365,7 @@ then delete CATEGORY from the category set instead of adding it.  */)
   if (NILP (CATEGORY_DOCSTRING (table, XFASTINT (category))))
     error ("Undefined category: %c", (int) XFASTINT (category));
 
-  set_value = NILP (reset) ? Qt : Qnil;
+  set_value = NILP (reset);
 
   while (start <= end)
     {
@@ -395,7 +374,7 @@ then delete CATEGORY from the category set instead of adding it.  */)
       if (CATEGORY_MEMBER (XFASTINT (category), category_set) != NILP (reset))
        {
          category_set = Fcopy_sequence (category_set);
-         SET_CATEGORY_SET (category_set, category, set_value);
+         set_category_set (category_set, XFASTINT (category), set_value);
          category_set = hash_get_category_set (table, category_set);
          char_table_set_range (table, start, to, category_set);
        }
@@ -460,14 +439,6 @@ init_category_once (void)
 {
   /* This has to be done here, before we call Fmake_char_table.  */
   DEFSYM (Qcategory_table, "category-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");
-
-  /* Now we are ready to set up this property, so we can
-     create category tables.  */
   Fput (Qcategory_table, Qchar_table_extra_slots, make_number (2));
 
   Vstandard_category_table = Fmake_char_table (Qcategory_table, Qnil);
@@ -518,7 +489,7 @@ between C1 and C2.
 
 For instance, to tell that there's a word boundary between Hiragana
 and Katakana (both are in the same script `kana'),
-the element `(?H . ?K) should be in this list.  */);
+the element `(?H . ?K)' should be in this list.  */);
 
   Vword_combining_categories = Qnil;