/* Basic character set support.
- Copyright (C) 2001, 2002, 2003, 2004, 2005,
- 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+ 2008 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007
+ 2005, 2006, 2007, 2008
National Institute of Advanced Industrial Science and Technology (AIST)
Registration Number H14PRO021
This file is part of GNU Emacs.
-GNU Emacs is free software; you can redistribute it and/or modify
+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, 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
Lisp_Object Qeight_bit;
Lisp_Object Qiso_8859_1;
Lisp_Object Qunicode;
+Lisp_Object Qemacs;
/* The corresponding charsets. */
int charset_ascii;
int charset_eight_bit;
int charset_iso_8859_1;
int charset_unicode;
+int charset_emacs;
/* The other special charsets. */
int charset_jisx0201_roman;
/* List of charsets ordered by the priority. */
Lisp_Object Vcharset_ordered_list;
+/* Sub-list of Vcharset_ordered_list that contains all non-preferred
+ 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. */
Lisp_Object Vchar_unified_charset_table;
+Lisp_Object Vcurrent_iso639_language;
+
/* Defined in chartab.c */
extern void
map_char_table_for_charset P_ ((void (*c_function) (Lisp_Object, Lisp_Object),
else if (ISO_CHARSET_TABLE (2, 0, 'B') == id)
charset_jisx0208 = id;
}
-
+
if (charset.emacs_mule_id >= 0)
{
emacs_mule_charset[charset.emacs_mule_id] = CHARSET_FROM_ID (id);
if (new_definition_p)
{
Vcharset_list = Fcons (args[charset_arg_name], Vcharset_list);
- Vcharset_ordered_list = nconc2 (Vcharset_ordered_list,
- Fcons (make_number (id), Qnil));
+ if (charset.supplementary_p)
+ Vcharset_ordered_list = nconc2 (Vcharset_ordered_list,
+ Fcons (make_number (id), Qnil));
+ else
+ {
+ Lisp_Object tail;
+
+ for (tail = Vcharset_ordered_list; CONSP (tail); tail = XCDR (tail))
+ {
+ struct charset *cs = CHARSET_FROM_ID (XINT (XCAR (tail)));
+
+ if (cs->supplementary_p)
+ break;
+ }
+ if (EQ (tail, Vcharset_ordered_list))
+ Vcharset_ordered_list = Fcons (make_number (id),
+ Vcharset_ordered_list);
+ else if (NILP (tail))
+ Vcharset_ordered_list = nconc2 (Vcharset_ordered_list,
+ Fcons (make_number (id), Qnil));
+ else
+ {
+ val = Fcons (XCAR (tail), XCDR (tail));
+ XSETCDR (tail, val);
+ XSETCAR (tail, make_number (id));
+ }
+ }
charset_ordered_list_tick++;
}
}
-DEFUN ("unibyte-charset", Funibyte_charset, Sunibyte_charset, 0, 0, 0,
- doc: /* Return the unibyte charset (set by `set-unibyte-charset'). */)
- ()
-{
- return CHARSET_NAME (CHARSET_FROM_ID (charset_unibyte));
-}
-
-
-DEFUN ("set-unibyte-charset", Fset_unibyte_charset, Sset_unibyte_charset,
- 1, 1, 0,
- doc: /* Set the unibyte charset to CHARSET.
-This determines how unibyte/multibyte conversion is done. See also
-function `unibyte-charset'. */)
- (charset)
- Lisp_Object charset;
-{
- struct charset *cs;
- int i, c;
-
- CHECK_CHARSET_GET_CHARSET (charset, cs);
- if (! cs->ascii_compatible_p
- || cs->dimension != 1)
- error ("Inappropriate unibyte charset: %s", SDATA (SYMBOL_NAME (charset)));
- charset_unibyte = cs->id;
- memset (unibyte_has_multibyte_table, 1, 128);
- for (i = 128; i < 256; i++)
- {
- c = DECODE_CHAR (cs, i);
- unibyte_to_multibyte_table[i] = (c < 0 ? BYTE8_TO_CHAR (i) : c);
- unibyte_has_multibyte_table[i] = c >= 0;
- }
-
- return Qnil;
-}
-
-
DEFUN ("charset-plist", Fcharset_plist, Scharset_plist, 1, 1, 0,
doc: /* Return the property list of CHARSET. */)
(charset)
DEFUN ("get-unused-iso-final-char", Fget_unused_iso_final_char,
Sget_unused_iso_final_char, 2, 2, 0,
doc: /*
-Return an unused ISO final char for a charset of DIMENISION and CHARS.
+Return an unused ISO final char for a charset of DIMENSION and CHARS.
DIMENSION is the number of bytes to represent a character: 1 or 2.
CHARS is the number of characters in a dimension: 94 or 96.
CODE-POINT may be a cons (HIGHER-16-BIT-VALUE . LOWER-16-BIT-VALUE).
Optional argument RESTRICTION specifies a way to map the pair of CCS
-and CODE-POINT to a chracter. Currently not supported and just ignored. */)
+and CODE-POINT to a character. Currently not supported and just ignored. */)
(charset, code_point, restriction)
Lisp_Object charset, code_point, restriction;
{
doc: /* Encode the character CH into a code-point of CHARSET.
Return nil if CHARSET doesn't include CH.
-Optional argument RESTRICTION specifies a way to map CHAR to a
+Optional argument RESTRICTION specifies a way to map CH to a
code-point in CCS. Currently not supported and just ignored. */)
(ch, charset, restriction)
Lisp_Object ch, charset, restriction;
Lisp_Object charset_list;
unsigned *code_return;
{
+ int maybe_null = 0;
+
if (NILP (charset_list))
charset_list = Vcharset_ordered_list;
+ else
+ maybe_null = 1;
while (CONSP (charset_list))
{
return charset;
}
charset_list = XCDR (charset_list);
+ if (c <= MAX_UNICODE_CHAR
+ && EQ (charset_list, Vcharset_non_preferred_head))
+ return CHARSET_FROM_ID (charset_unicode);
}
- return NULL;
+ return (maybe_null ? NULL
+ : c <= MAX_5_BYTE_CHAR ? CHARSET_FROM_ID (charset_emacs)
+ : CHARSET_FROM_ID (charset_eight_bit));
}
DEFUN ("split-char", Fsplit_char, Ssplit_char, 1, 1, 0,
doc:
- /*Return list of charset and one to four position-codes of CHAR.
+ /*Return list of charset and one to four position-codes of CH.
The charset is decided by the current priority order of charsets.
A position-code is a byte value of each dimension of the code-point of
-CHAR in the charset. */)
+CH in the charset. */)
(ch)
Lisp_Object ch;
{
ISO 2022's designation sequence (escape sequence) distinguishes charsets
by their DIMENSION, CHARS, and FINAL-CHAR,
-where as Emacs distinguishes them by charset symbol.
+whereas Emacs distinguishes them by charset symbol.
See the documentation of the function `charset-info' for the meanings of
DIMENSION, CHARS, and FINAL-CHAR. */)
(dimension, chars, final_char)
if (CHAR_TABLE_P (Vchar_unified_charset_table))
{
- Foptimize_char_table (Vchar_unified_charset_table);
+ Foptimize_char_table (Vchar_unified_charset_table, Qnil);
Vchar_unify_table = Vchar_unified_charset_table;
Vchar_unified_charset_table = Qnil;
}
}
}
arglist[0] = Fnreverse (new_head);
- arglist[1] = old_list;
+ arglist[1] = Vcharset_non_preferred_head = old_list;
Vcharset_ordered_list = Fnconc (2, arglist);
charset_ordered_list_tick++;
void
init_charset ()
{
- Vcharset_map_path
- = Fcons (Fexpand_file_name (build_string ("charsets"), Vdata_directory),
- Qnil);
+ Lisp_Object tempdir;
+ tempdir = Fexpand_file_name (build_string ("charsets"), Vdata_directory);
+ if (access (SDATA (tempdir), 0) < 0)
+ {
+ dir_warning ("Error: charsets directory (%s) does not exist.\n\
+Emacs will not function correctly without the character map files.\n\
+Please check your installation!\n",
+ tempdir);
+ /* TODO should this be a fatal error? (Bug#909) */
+ }
+
+ Vcharset_map_path = Fcons (tempdir, Qnil);
}
DEFSYM (Qascii, "ascii");
DEFSYM (Qunicode, "unicode");
+ DEFSYM (Qemacs, "emacs");
DEFSYM (Qeight_bit, "eight-bit");
DEFSYM (Qiso_8859_1, "iso-8859-1");
staticpro (&Vemacs_mule_charset_list);
Vemacs_mule_charset_list = Qnil;
+ /* Don't staticpro them here. It's done in syms_of_fns. */
+ QCtest = intern (":test");
+ Qeq = intern ("eq");
+
staticpro (&Vcharset_hash_table);
{
Lisp_Object args[2];
defsubr (&Smap_charset_chars);
defsubr (&Sdefine_charset_internal);
defsubr (&Sdefine_charset_alias);
- defsubr (&Sunibyte_charset);
- defsubr (&Sset_unibyte_charset);
defsubr (&Scharset_plist);
defsubr (&Sset_charset_plist);
defsubr (&Sunify_charset);
defsubr (&Scharset_id_internal);
DEFVAR_LISP ("charset-map-path", &Vcharset_map_path,
- doc: /* *Lisp of directories to search for charset map files. */);
+ doc: /* *List of directories to search for charset map files. */);
Vcharset_map_path = Qnil;
DEFVAR_LISP ("charset-list", &Vcharset_list,
doc: /* List of all charsets ever defined. */);
Vcharset_list = Qnil;
+ DEFVAR_LISP ("current-iso639-language", &Vcurrent_iso639_language,
+ doc: /* ISO639 language mnemonic symbol for the current language environment.
+If the current language environment is for multiple languages (e.g. "Latin-1"),
+the value may be a list of mnemonics. */);
+ Vcurrent_iso639_language = Qnil;
+
charset_ascii
= define_charset_internal (Qascii, 1, "\x00\x7F\x00\x00\x00\x00",
0, 127, 'B', -1, 0, 1, 0, 0);
charset_unicode
= define_charset_internal (Qunicode, 3, "\x00\xFF\x00\xFF\x00\x10",
0, MAX_UNICODE_CHAR, -1, 0, -1, 1, 0, 0);
+ charset_emacs
+ = define_charset_internal (Qemacs, 3, "\x00\xFF\x00\xFF\x00\x3F",
+ 0, MAX_5_BYTE_CHAR, -1, 0, -1, 1, 1, 0);
charset_eight_bit
= define_charset_internal (Qeight_bit, 1, "\x80\xFF\x00\x00\x00\x00",
- 128, 255, -1, 0, -1, 0, 0,
+ 128, 255, -1, 0, -1, 0, 1,
MAX_5_BYTE_CHAR + 1);
}