]> code.delx.au - gnu-emacs/blobdiff - src/casetab.c
Don't declare logb if it is a macro.
[gnu-emacs] / src / casetab.c
index 6d419bfe30fd3152c765be83263222fe15ccc876..34a81dc9b06cf5a3451eb7a2a1fb8d9794f165d7 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU Emacs routines to deal with case tables.
-   Copyright (C) 1987 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -19,7 +19,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 /* Written by Howard Gayle.  See chartab.c for details. */
 
-#include "config.h"
+#include <config.h>
 #include "lisp.h"
 #include "buffer.h"
 
@@ -45,9 +45,10 @@ See `set-case-table' for more information on these data structures.")
   (XTYPE (obj) == Lisp_String && XSTRING (obj)->size == 256)
 
   return (STRING256_P (down)
-         && (NULL (up) || STRING256_P (up))
-         && ((NULL (canon) && NULL (eqv))
-             || (STRING256_P (canon) && STRING256_P (eqv)))
+         && (NILP (up) || STRING256_P (up))
+         && ((NILP (canon) && NILP (eqv))
+             || (STRING256_P (canon)
+                 && (NILP (eqv) || STRING256_P (eqv))))
          ? Qt : Qnil);
 }
 
@@ -57,8 +58,8 @@ check_case_table (obj)
 {
   register Lisp_Object tem;
 
-  while (tem = Fcase_table_p (obj), NULL (tem))
-    obj = wrong_type_argument (Qcase_table_p, obj, 0);
+  while (tem = Fcase_table_p (obj), NILP (tem))
+    obj = wrong_type_argument (Qcase_table_p, obj);
   return (obj);
 }   
 
@@ -76,8 +77,7 @@ DEFUN ("current-case-table", Fcurrent_case_table, Scurrent_case_table, 0, 0, 0,
   return Fcons (down, Fcons (up, Fcons (canon, Fcons (eqv, Qnil))));
 }
 
-DEFUN ("standard-case-table", Fstandard_case_table,
-  Sstandard_case_table, 0, 0, 0,
+DEFUN ("standard-case-table", Fstandard_case_table, Sstandard_case_table, 0, 0, 0,
   "Return the standard case table.\n\
 This is the one used for new buffers.")
   ()
@@ -88,6 +88,8 @@ This is the one used for new buffers.")
                              Fcons (Vascii_eqv_table, Qnil))));
 }
 
+static Lisp_Object set_case_table ();
+
 DEFUN ("set-case-table", Fset_case_table, Sset_case_table, 1, 1, 0,
   "Select a new case table for the current buffer.\n\
 A case table is a list (DOWNCASE UPCASE CANONICALIZE EQUIVALENCES)\n\
@@ -98,27 +100,27 @@ UPCASE maps each character to its upper-case equivalent;\n\
  you may use nil and the upcase table will be deduced from DOWNCASE.\n\
 CANONICALIZE maps each character to a canonical equivalent;\n\
  any two characters that are related by case-conversion have the same\n\
- canonical equivalent character.\n\
+ canonical equivalent character; it may be nil, in which case it is\n\
+ deduced from DOWNCASE and UPCASE.\n\
 EQUIVALENCES is a map that cyclicly permutes each equivalence class\n\
- (of characters with the same canonical equivalent).\n\
-Both CANONICALIZE and EQUIVALENCES may be nil, in which case\n\
- both are deduced from DOWNCASE and UPCASE.")
+ (of characters with the same canonical equivalent); it may be nil,\n\
+ in which case it is deduced from CANONICALIZE.")
   (table)
      Lisp_Object table;
 {
-  set_case_table (table, 0);
+  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,
   "Select a new standard case table for new buffers.\n\
 See `set-case-table' for more info on case tables.")
   (table)
      Lisp_Object table;
 {
-  set_case_table (table, 1);
+  return set_case_table (table, 1);
 }
 
+static Lisp_Object
 set_case_table (table, standard)
      Lisp_Object table;
      int standard;
@@ -132,26 +134,30 @@ set_case_table (table, standard)
   canon = Fcar_safe (Fcdr_safe (Fcdr_safe (table)));
   eqv = Fcar_safe (Fcdr_safe (Fcdr_safe (Fcdr_safe (table))));
 
-  if (NULL (up))
+  if (NILP (up))
     {
       up = Fmake_string (make_number (256), make_number (0));
       compute_trt_inverse (XSTRING (down)->data, XSTRING (up)->data);
     }
 
-  if (NULL (canon))
+  if (NILP (canon))
     {
       register int i;
       unsigned char *upvec = XSTRING (up)->data;
       unsigned char *downvec = XSTRING (down)->data;
 
       canon = Fmake_string (make_number (256), make_number (0));
-      eqv = Fmake_string (make_number (256), make_number (0));
 
       /* Set up the CANON vector; for each character,
         this sequence of upcasing and downcasing ought to
         get the "preferred" lowercase equivalent.  */
       for (i = 0; i < 256; i++)
        XSTRING (canon)->data[i] = downvec[upvec[downvec[i]]];
+    }
+
+  if (NILP (eqv))
+    {
+      eqv = Fmake_string (make_number (256), make_number (0));
 
       compute_trt_inverse (XSTRING (canon)->data, XSTRING (eqv)->data);
     }