character sequence of emacs-utf-8 to a byte sequence of a specific
coding system.
- In Emacs Lisp, a coding system is represented by a Lisp symbol. In
- C level, a coding system is represented by a vector of attributes
+ In Emacs Lisp, a coding system is represented by a Lisp symbol. On
+ the C level, a coding system is represented by a vector of attributes
stored in the hash table Vcharset_hash_table. The conversion from
coding system symbol to attributes vector is done by looking up
Vcharset_hash_table by the symbol.
static Lisp_Object get_translation_table (Lisp_Object, int, int *);
static Lisp_Object get_translation (Lisp_Object, int *, int *);
static int produce_chars (struct coding_system *, Lisp_Object, int);
-static INLINE void produce_charset (struct coding_system *, int *,
+static inline void produce_charset (struct coding_system *, int *,
EMACS_INT);
static void produce_annotation (struct coding_system *, EMACS_INT);
static int decode_coding (struct coding_system *);
-static INLINE int *handle_composition_annotation (EMACS_INT, EMACS_INT,
+static inline int *handle_composition_annotation (EMACS_INT, EMACS_INT,
struct coding_system *,
int *, EMACS_INT *);
-static INLINE int *handle_charset_annotation (EMACS_INT, EMACS_INT,
+static inline int *handle_charset_annotation (EMACS_INT, EMACS_INT,
struct coding_system *,
int *, EMACS_INT *);
static void consume_chars (struct coding_system *, Lisp_Object, int);
static int encode_coding (struct coding_system *);
static Lisp_Object make_conversion_work_buffer (int);
static Lisp_Object code_conversion_restore (Lisp_Object);
-static INLINE int char_encodable_p (int, Lisp_Object);
+static inline int char_encodable_p (int, Lisp_Object);
static Lisp_Object make_subsidiaries (Lisp_Object);
static void
static void
coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes)
{
+ if (STRING_BYTES_BOUND - coding->dst_bytes < bytes)
+ string_overflow ();
coding->destination = (unsigned char *) xrealloc (coding->destination,
coding->dst_bytes + bytes);
coding->dst_bytes += bytes;
/* We may produce two annotations (charset and composition) in one
loop and one more charset annotation at the end. */
int *charbuf_end
- = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3);
+ = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3)
+ /* We can produce up to 2 characters in a loop. */
+ - 1;
EMACS_INT consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
EMACS_INT char_offset = coding->produced_char;
{
int i;
+ if (charbuf_end - charbuf < cmp_status->length)
+ abort ();
for (i = 0; i < cmp_status->length; i++)
*charbuf++ = cmp_status->carryover[i];
coding->annotated = 1;
if (cmp_status->state != COMPOSING_NO)
{
+ if (charbuf_end - charbuf < cmp_status->length)
+ abort ();
for (i = 0; i < cmp_status->length; i++)
*charbuf++ = cmp_status->carryover[i];
coding->annotated = 1;
if (src == src_end)
goto too_short;
ONE_MORE_BYTE (c);
- if (c < charset->code_space[(dim - 1 - idx) * 2]
- || c > charset->code_space[(dim - 1 - idx) * 2 + 1])
+ if (c < charset->code_space[(dim - 1 - idx) * 4]
+ || c > charset->code_space[(dim - 1 - idx) * 4 + 1])
break;
}
if (idx < dim)
[ -LENGTH ANNOTATION_MASK NCHARS NBYTES METHOD [ COMPONENTS... ] ]
*/
-static INLINE void
+static inline void
produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos)
{
int len;
[ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ]
*/
-static INLINE void
+static inline void
produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos)
{
EMACS_INT from = pos - charbuf[2];
position of a composition after POS (if any) or to LIMIT, and
return BUF. */
-static INLINE int *
+static inline int *
handle_composition_annotation (EMACS_INT pos, EMACS_INT limit,
struct coding_system *coding, int *buf,
EMACS_INT *stop)
components = COMPOSITION_COMPONENTS (prop);
if (VECTORP (components))
{
- len = XVECTOR (components)->size;
+ len = ASIZE (components);
for (i = 0; i < len; i++)
*buf++ = XINT (AREF (components, i));
}
If the property value is nil, set *STOP to the position where the
property value is non-nil (limiting by LIMIT), and return BUF. */
-static INLINE int *
+static inline int *
handle_charset_annotation (EMACS_INT pos, EMACS_INT limit,
struct coding_system *coding, int *buf,
EMACS_INT *stop)
#ifdef emacs
/*** 8. Emacs Lisp library functions ***/
-DEFUE ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0,
+DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0,
doc: /* Return t if OBJECT is nil or a coding-system.
See the documentation of `define-coding-system' for information
about coding-system objects. */)
return Qt;
}
-DEFUE ("read-non-nil-coding-system", Fread_non_nil_coding_system,
+DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system,
Sread_non_nil_coding_system, 1, 1, 0,
doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. */)
(Lisp_Object prompt)
return (Fintern (val, Qnil));
}
-DEFUE ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0,
+DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0,
doc: /* Read a coding system from the minibuffer, prompting with string PROMPT.
If the user enters null input, return second argument DEFAULT-CODING-SYSTEM.
Ignores case when completing coding systems (all Emacs coding systems
return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil));
}
-DEFUE ("check-coding-system", Fcheck_coding_system, Scheck_coding_system,
+DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system,
1, 1, 0,
doc: /* Check validity of CODING-SYSTEM.
If valid, return CODING-SYSTEM, else signal a `coding-system-error' error.
}
-static INLINE int
+static inline int
char_encodable_p (int c, Lisp_Object attrs)
{
Lisp_Object tail;
}
-DEFUE ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string,
+DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string,
2, 4, 0,
doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result.
(Lisp_Object string, Lisp_Object coding_system, Lisp_Object nocopy, Lisp_Object buffer)
{
return code_convert_string (string, coding_system, buffer,
- 1, ! NILP (nocopy), 1);
+ 1, ! NILP (nocopy), 0);
}
\f
if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF
|| c2 < 0x40 || c2 == 0x7F || c2 > 0xFC)
- error ("Invalid code: %"pEd, ch);
+ error ("Invalid code: %"pI"d", ch);
c = ch;
SJIS_TO_JIS (c);
charset = charset_kanji;
}
c = DECODE_CHAR (charset, c);
if (c < 0)
- error ("Invalid code: %"pEd, ch);
+ error ("Invalid code: %"pI"d", ch);
return make_number (c);
}
charset_list = CODING_ATTR_CHARSET_LIST (attrs);
charset = char_charset (c, charset_list, &code);
if (code == CHARSET_INVALID_CODE (charset))
- error ("Can't encode by shift_jis encoding: %d", c);
+ error ("Can't encode by shift_jis encoding: %c", c);
JIS_TO_SJIS (code);
return make_number (code);
int b2 = ch & 0x7F;
if (b1 < 0xA1 || b1 > 0xFE
|| b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE)
- error ("Invalid code: %"pEd, ch);
+ error ("Invalid code: %"pI"d", ch);
c = ch;
charset = charset_big5;
}
c = DECODE_CHAR (charset, c);
if (c < 0)
- error ("Invalid code: %"pEd, ch);
+ error ("Invalid code: %"pI"d", ch);
return make_number (c);
}
charset_list = CODING_ATTR_CHARSET_LIST (attrs);
charset = char_charset (c, charset_list, &code);
if (code == CHARSET_INVALID_CODE (charset))
- error ("Can't encode by Big5 encoding: %d", c);
+ error ("Can't encode by Big5 encoding: %c", c);
return make_number (code);
}
}
\f
-DEFUE ("find-operation-coding-system", Ffind_operation_coding_system,
+DEFUN ("find-operation-coding-system", Ffind_operation_coding_system,
Sfind_operation_coding_system, 1, MANY, 0,
doc: /* Choose a coding system for an operation based on the target name.
The value names a pair of coding systems: (DECODING-SYSTEM . ENCODING-SYSTEM).
contents of BUFFER instead of reading the file.
usage: (find-operation-coding-system OPERATION ARGUMENTS...) */)
- (size_t nargs, Lisp_Object *args)
+ (ptrdiff_t nargs, Lisp_Object *args)
{
Lisp_Object operation, target_idx, target, val;
register Lisp_Object chain;
|| !NATNUMP (target_idx = Fget (operation, Qtarget_idx)))
error ("Invalid first argument");
if (nargs < 1 + XFASTINT (target_idx))
- error ("Too few arguments for operation: %s",
+ error ("Too few arguments for operation `%s'",
SDATA (SYMBOL_NAME (operation)));
target = args[XFASTINT (target_idx) + 1];
if (!(STRINGP (target)
|| (EQ (operation, Qinsert_file_contents) && CONSP (target)
&& STRINGP (XCAR (target)) && BUFFERP (XCDR (target)))
|| (EQ (operation, Qopen_network_stream) && INTEGERP (target))))
- error ("Invalid %"pEd"th argument", XFASTINT (target_idx) + 1);
+ error ("Invalid argument %"pI"d of operation `%s'",
+ XFASTINT (target_idx) + 1, SDATA (SYMBOL_NAME (operation)));
if (CONSP (target))
target = XCAR (target);
all but the first one are ignored.
usage: (set-coding-system-priority &rest coding-systems) */)
- (size_t nargs, Lisp_Object *args)
+ (ptrdiff_t nargs, Lisp_Object *args)
{
- size_t i, j;
+ ptrdiff_t i, j;
int changed[coding_category_max];
enum coding_category priorities[coding_category_max];
make_subsidiaries (Lisp_Object base)
{
Lisp_Object subsidiaries;
- int base_name_len = SBYTES (SYMBOL_NAME (base));
+ ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base));
char *buf = (char *) alloca (base_name_len + 6);
int i;
subsidiaries = Fmake_vector (make_number (3), Qnil);
for (i = 0; i < 3; i++)
{
- memcpy (buf + base_name_len, suffixes[i], strlen (suffixes[i]) + 1);
+ strcpy (buf + base_name_len, suffixes[i]);
ASET (subsidiaries, i, intern (buf));
}
return subsidiaries;
Sdefine_coding_system_internal, coding_arg_max, MANY, 0,
doc: /* For internal use only.
usage: (define-coding-system-internal ...) */)
- (size_t nargs, Lisp_Object *args)
+ (ptrdiff_t nargs, Lisp_Object *args)
{
Lisp_Object name;
Lisp_Object spec_vec; /* [ ATTRS ALIASE EOL_TYPE ] */
CHECK_CHARSET_GET_ID (tmp1, id);
CHECK_NATNUM_CDR (val);
if (XINT (XCDR (val)) >= 4)
- error ("Invalid graphic register number: %"pEd, XINT (XCDR (val)));
+ error ("Invalid graphic register number: %"pI"d", XINT (XCDR (val)));
XSETCAR (val, make_number (id));
}
return Qnil;
}
-DEFUE ("coding-system-base", Fcoding_system_base, Scoding_system_base,
+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 system is not a base coding system. */)
return AREF (spec, 1);
}
-DEFUE ("coding-system-eol-type", Fcoding_system_eol_type,
+DEFUN ("coding-system-eol-type", Fcoding_system_eol_type,
Scoding_system_eol_type, 1, 1, 0,
doc: /* Return eol-type of CODING-SYSTEM.
An eol-type is an integer 0, 1, 2, or a vector of coding systems.