/* Basic character set support.
-Copyright (C) 2001-2014 Free Software Foundation, Inc.
+Copyright (C) 2001-2015 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007, 2008, 2009, 2010, 2011
static ptrdiff_t charset_table_size;
static int charset_table_used;
-Lisp_Object Qcharsetp;
-
-/* Special charset symbols. */
-Lisp_Object Qascii;
-static Lisp_Object Qeight_bit;
-static Lisp_Object Qiso_8859_1;
-static Lisp_Object Qunicode;
-static Lisp_Object Qemacs;
-
-/* The corresponding charsets. */
+/* Special charsets corresponding to symbols. */
int charset_ascii;
int charset_eight_bit;
static int charset_iso_8859_1;
int charset_jisx0208;
int charset_ksc5601;
-/* Value of charset attribute `charset-iso-plane'. */
-static Lisp_Object Qgl, Qgr;
-
/* Charset of unibyte characters. */
int charset_unibyte;
charsets. */
Lisp_Object Vcharset_non_preferred_head;
-/* Incremented everytime we change Vcharset_ordered_list. This is
- unsigned short so that it fits in Lisp_Int and never matches
- -1. */
-unsigned short charset_ordered_list_tick;
+/* Incremented every time we change the priority of charsets.
+ Wraps around. */
+EMACS_UINT charset_ordered_list_tick;
/* List of iso-2022 charsets. */
Lisp_Object Viso_2022_charset_list;
{
if (ascii_compatible_p)
{
- if (! ASCII_BYTE_P (from_c))
+ if (! ASCII_CHAR_P (from_c))
{
if (from_c < nonascii_min_char)
nonascii_min_char = from_c;
}
- else if (! ASCII_BYTE_P (to_c))
+ else if (! ASCII_CHAR_P (to_c))
{
nonascii_min_char = 0x80;
}
unsigned max_code = CHARSET_MAX_CODE (charset);
int fd;
FILE *fp;
- Lisp_Object suffixes;
struct charset_map_entries *head, *entries;
int n_entries;
- ptrdiff_t count;
-
- suffixes = list2 (build_string (".map"), build_string (".TXT"));
-
- count = SPECPDL_INDEX ();
+ AUTO_STRING (map, ".map");
+ AUTO_STRING (txt, ".txt");
+ AUTO_LIST2 (suffixes, map, txt);
+ ptrdiff_t count = SPECPDL_INDEX ();
record_unwind_protect_nothing ();
specbind (Qfile_name_handler_alist, Qnil);
fd = openp (Vcharset_map_path, mapfile, suffixes, NULL, Qnil, false);
{
int from_idx = CODE_POINT_TO_INDEX (temp_charset_work->current, from);
int to_idx = CODE_POINT_TO_INDEX (temp_charset_work->current, to);
- Lisp_Object range;
+ Lisp_Object range = Fcons (Qnil, Qnil);
int c, stop;
- struct gcpro gcpro1;
-
- range = Fcons (Qnil, Qnil);
- GCPRO1 (range);
c = temp_charset_work->min_char;
stop = (temp_charset_work->max_char < 0x20000
}
c++;
}
- UNGCPRO;
}
void
return Qnil;
}
+/* Check that DIMENSION, CHARS, and FINAL_CHAR specify a valid ISO charset.
+ Return true if it's a 96-character set, false if 94. */
+
+static bool
+check_iso_charset_parameter (Lisp_Object dimension, Lisp_Object chars,
+ Lisp_Object final_char)
+{
+ CHECK_NUMBER (dimension);
+ CHECK_NUMBER (chars);
+ CHECK_CHARACTER (final_char);
+
+ if (! (1 <= XINT (dimension) && XINT (dimension) <= 3))
+ error ("Invalid DIMENSION %"pI"d, it should be 1, 2, or 3",
+ XINT (dimension));
+
+ bool chars_flag = XINT (chars) == 96;
+ if (! (chars_flag || XINT (chars) == 94))
+ error ("Invalid CHARS %"pI"d, it should be 94 or 96", XINT (chars));
+
+ int final_ch = XFASTINT (final_char);
+ if (! ('0' <= final_ch && final_ch <= '~'))
+ error ("Invalid FINAL-CHAR '%c', it should be '0'..'~'", final_ch);
+
+ return chars_flag;
+}
+
DEFUN ("get-unused-iso-final-char", Fget_unused_iso_final_char,
Sget_unused_iso_final_char, 2, 2, 0,
doc: /*
return nil. */)
(Lisp_Object dimension, Lisp_Object chars)
{
- int final_char;
-
- CHECK_NUMBER (dimension);
- CHECK_NUMBER (chars);
- if (XINT (dimension) != 1 && XINT (dimension) != 2 && XINT (dimension) != 3)
- args_out_of_range_3 (dimension, make_number (1), make_number (3));
- if (XINT (chars) != 94 && XINT (chars) != 96)
- args_out_of_range_3 (chars, make_number (94), make_number (96));
- for (final_char = '0'; final_char <= '?'; final_char++)
- if (ISO_CHARSET_TABLE (XINT (dimension), XINT (chars), final_char) < 0)
- break;
- return (final_char <= '?' ? make_number (final_char) : Qnil);
-}
-
-static void
-check_iso_charset_parameter (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char)
-{
- CHECK_NATNUM (dimension);
- CHECK_NATNUM (chars);
- CHECK_CHARACTER (final_char);
-
- if (XINT (dimension) > 3)
- error ("Invalid DIMENSION %"pI"d, it should be 1, 2, or 3",
- XINT (dimension));
- if (XINT (chars) != 94 && XINT (chars) != 96)
- error ("Invalid CHARS %"pI"d, it should be 94 or 96", XINT (chars));
- if (XINT (final_char) < '0' || XINT (final_char) > '~')
- error ("Invalid FINAL-CHAR %c, it should be `0'..`~'",
- (int)XINT (final_char));
+ bool chars_flag = check_iso_charset_parameter (dimension, chars,
+ make_number ('0'));
+ for (int final_char = '0'; final_char <= '?'; final_char++)
+ if (ISO_CHARSET_TABLE (XINT (dimension), chars_flag, final_char) < 0)
+ return make_number (final_char);
+ return Qnil;
}
(Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char, Lisp_Object charset)
{
int id;
- bool chars_flag;
CHECK_CHARSET_GET_ID (charset, id);
- check_iso_charset_parameter (dimension, chars, final_char);
- chars_flag = XINT (chars) == 96;
- ISO_CHARSET_TABLE (XINT (dimension), chars_flag, XINT (final_char)) = id;
+ bool chars_flag = check_iso_charset_parameter (dimension, chars, final_char);
+ ISO_CHARSET_TABLE (XINT (dimension), chars_flag, XFASTINT (final_char)) = id;
return Qnil;
}
if (!NILP (table))
c = translate_char (table, c);
- if (ASCII_BYTE_P (c))
+ if (ASCII_CHAR_P (c))
ASET (charsets, charset_ascii, Qt);
else
ASET (charsets, charset_eight_bit, Qt);
DIMENSION, CHARS, and FINAL-CHAR. */)
(Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char)
{
- int id;
- bool chars_flag;
-
- check_iso_charset_parameter (dimension, chars, final_char);
- chars_flag = XFASTINT (chars) == 96;
- id = ISO_CHARSET_TABLE (XFASTINT (dimension), chars_flag,
- XFASTINT (final_char));
+ bool chars_flag = check_iso_charset_parameter (dimension, chars, final_char);
+ int id = ISO_CHARSET_TABLE (XINT (dimension), chars_flag,
+ XFASTINT (final_char));
return (id >= 0 ? CHARSET_NAME (CHARSET_FROM_ID (id)) : Qnil);
}
{
Lisp_Object tempdir;
tempdir = Fexpand_file_name (build_string ("charsets"), Vdata_directory);
- if (! file_accessible_directory_p (SSDATA (tempdir)))
+ if (! file_accessible_directory_p (tempdir))
{
/* This used to be non-fatal (dir_warning), but it should not
happen, and if it does sooner or later it will cause some
{
DEFSYM (Qcharsetp, "charsetp");
+ /* Special charset symbols. */
DEFSYM (Qascii, "ascii");
DEFSYM (Qunicode, "unicode");
DEFSYM (Qemacs, "emacs");
DEFSYM (Qeight_bit, "eight-bit");
DEFSYM (Qiso_8859_1, "iso-8859-1");
+ /* Value of charset attribute `charset-iso-plane'. */
DEFSYM (Qgl, "gl");
DEFSYM (Qgr, "gr");
staticpro (&Vemacs_mule_charset_list);
Vemacs_mule_charset_list = Qnil;
- /* Don't staticpro them here. It's done in syms_of_fns. */
- QCtest = intern_c_string (":test");
- Qeq = intern_c_string ("eq");
-
staticpro (&Vcharset_hash_table);
{
Lisp_Object args[2];