/* 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.
/* Written by Howard Gayle. See chartab.c for details. */
-#include "config.h"
+#include <config.h>
#include "lisp.h"
#include "buffer.h"
(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);
}
{
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);
}
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.")
()
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\
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;
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);
}