(CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0)
static void
-setup_iso_safe_charsets (Lisp_Object attrs)
+setup_iso_safe_charsets (attrs)
+ Lisp_Object attrs;
{
Lisp_Object charset_list, safe_charsets;
Lisp_Object request;
ONE_MORE_BYTE (c);
if (c == '\r')
{
+ /* Here we assume that no charset maps '\r' to something
+ else. */
if (EQ (eol_type, Qdos))
{
if (src < src_end
{
Lisp_Object val;
struct charset *charset;
- int c1;
+ int dim;
+ int len = 1;
+ unsigned code = c;
val = AREF (valids, c);
if (NILP (val))
goto invalid_code;
- charset = CHARSET_FROM_ID (XFASTINT (val));
- if (CHARSET_DIMENSION (charset) > 1)
+ if (INTEGERP (val))
{
- ONE_MORE_BYTE (c1);
- c = (c << 8) | c1;
- if (CHARSET_DIMENSION (charset) > 2)
+ charset = CHARSET_FROM_ID (XFASTINT (val));
+ dim = CHARSET_DIMENSION (charset);
+ while (len < dim)
{
- ONE_MORE_BYTE (c1);
- c = (c << 8) | c1;
- if (CHARSET_DIMENSION (charset) > 3)
+ ONE_MORE_BYTE (c);
+ code = (code << 8) | c;
+ len++;
+ }
+ CODING_DECODE_CHAR (coding, src, src_base, src_end,
+ charset, code, c);
+ }
+ else
+ {
+ /* VAL is a list of charset IDs. It is assured that the
+ list is sorted by charset dimensions (smaller one
+ comes first). */
+ while (CONSP (val))
+ {
+ charset = CHARSET_FROM_ID (XFASTINT (XCAR (val)));
+ dim = CHARSET_DIMENSION (charset);
+ while (len < dim)
{
- ONE_MORE_BYTE (c1);
- c = (c << 8) | c1;
+ ONE_MORE_BYTE (c);
+ code = (code << 8) | c;
+ len++;
}
+ CODING_DECODE_CHAR (coding, src, src_base,
+ src_end, charset, code, c);
+ if (c >= 0)
+ break;
+ val = XCDR (val);
}
}
- CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c);
if (c < 0)
goto invalid_code;
}
DEFUN ("set-coding-system-priority", Fset_coding_system_priority,
Sset_coding_system_priority, 1, MANY, 0,
- doc: /* Assign higher priority to coding systems given as arguments.
+ doc: /* Assign higher priority to the coding systems given as arguments.
usage: (set-coding-system-priority CODING-SYSTEM ...) */)
(nargs, args)
int nargs;
DEFUN ("coding-system-priority-list", Fcoding_system_priority_list,
Scoding_system_priority_list, 0, 1, 0,
- doc: /* Return a list of coding systems ordered by their priorities. */)
+ doc: /* Return a list of coding systems ordered by their priorities.
+HIGHESTP non-nil means just return the highest priority one. */)
(highestp)
Lisp_Object highestp;
{
return Fnreverse (val);
}
+static char *suffixes[] = { "-unix", "-dos", "-mac" };
+
static Lisp_Object
make_subsidiaries (base)
Lisp_Object base;
{
Lisp_Object subsidiaries;
- char *suffixes[] = { "-unix", "-dos", "-mac" };
int base_name_len = STRING_BYTES (XSYMBOL (base)->name);
char *buf = (char *) alloca (base_name_len + 6);
int i;
if (EQ (coding_type, Qcharset))
{
+ /* Generate a lisp vector of 256 elements. Each element is nil,
+ integer, or a list of charset IDs.
+
+ If Nth element is nil, the byte code N is invalid in this
+ coding system.
+
+ If Nth element is a number NUM, N is the first byte of a
+ charset whose ID is NUM.
+
+ If Nth element is a list of charset IDs, N is the first byte
+ of one of them. The list is sorted by dimensions of the
+ charsets. A charset of smaller dimension comes firtst.
+ */
val = Fmake_vector (make_number (256), Qnil);
for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
{
- struct charset *charset = CHARSET_FROM_ID (XINT (XCAR (tail)));
- int idx = (CHARSET_DIMENSION (charset) - 1) * 4;
-
+ struct charset *charset = CHARSET_FROM_ID (XFASTINT (XCAR (tail)));
+ int dim = CHARSET_DIMENSION (charset);
+ int idx = (dim - 1) * 4;
+
for (i = charset->code_space[idx];
i <= charset->code_space[idx + 1]; i++)
{
- if (NILP (AREF (val, i)))
- ASET (val, i, XCAR (tail));
+ Lisp_Object tmp, tmp2;
+ int dim2;
+
+ tmp = AREF (val, i);
+ if (NILP (tmp))
+ tmp = XCAR (tail);
+ else if (NUMBERP (tmp))
+ {
+ dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (tmp)));
+ if (dim < dim2)
+ tmp = Fcons (XCAR (tail), Fcons (tmp, Qnil));
+ else
+ tmp = Fcons (tmp, Fcons (XCAR (tail), Qnil));
+ }
else
- error ("Charsets conflicts in the first byte");
+ {
+ for (tmp2 = tmp; CONSP (tmp2); tmp2 = XCDR (tmp2))
+ {
+ dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (XCAR (tmp2))));
+ if (dim < dim2)
+ break;
+ }
+ if (NILP (tmp2))
+ tmp = nconc2 (tmp, Fcons (XCAR (tail), Qnil));
+ else
+ {
+ XSETCDR (tmp2, Fcons (XCAR (tmp2), XCDR (tmp2)));
+ XSETCAR (tmp2, XCAR (tail));
+ }
+ }
+ ASET (val, i, tmp);
}
}
ASET (attrs, coding_attr_charset_valids, val);
make_number (nargs)));
}
+/* Fixme: should this record the alias relationships for
+ diagnostics? */
DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias,
Sdefine_coding_system_alias, 2, 2, 0,
doc: /* Define ALIAS as an alias for CODING-SYSTEM. */)
DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base,
1, 1, 0,
doc: /* Return the base of CODING-SYSTEM.
-Any alias or subsidiary coding systems are not base coding system. */)
+Any alias or subsidiary coding system is not a base coding system. */)
(coding_system)
Lisp_Object coding_system;
{
DEFUN ("coding-system-aliases", Fcoding_system_aliases, Scoding_system_aliases,
1, 1, 0,
- doc: /* Return the list of aliases of CODING-SYSTEM.
-A base coding system is what made by `define-coding-system'.
-Any alias nor subsidiary coding systems are not base coding system. */)
+ doc: /* Return the list of aliases of CODING-SYSTEM. */)
(coding_system)
Lisp_Object coding_system;
{
if (NILP (coding_system))
coding_system = Qno_conversion;
CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec);
- return AREF (spec, 2);
+ return AREF (spec, 1);
}
DEFUN ("coding-system-eol-type", Fcoding_system_eol_type,