const unsigned char *src = coding->source;
const unsigned char *src_end = coding->source + coding->src_bytes;
int multibytep = coding->src_multibyte;
- int consumed_chars = 0;
+ EMACS_INT consumed_chars = 0;
int found = 0;
...;
unsigned char *dst = coding->destination + coding->produced;
unsigned char *dst_end = coding->destination + coding->dst_bytes;
unsigned char *adjusted_dst_end = dst_end - _MAX_BYTES_PRODUCED_IN_LOOP_;
- int produced_chars = 0;
+ EMACS_INT produced_chars = 0;
for (; charbuf < charbuf_end && dst < adjusted_dst_end; charbuf++)
{
Lisp_Object Vcoding_system_hash_table;
-Lisp_Object Qcoding_system, Qcoding_aliases, Qeol_type;
+static Lisp_Object Qcoding_system, Qeol_type;
+static Lisp_Object Qcoding_aliases;
Lisp_Object Qunix, Qdos;
Lisp_Object Qbuffer_file_coding_system;
-Lisp_Object Qpost_read_conversion, Qpre_write_conversion;
-Lisp_Object Qdefault_char;
+static Lisp_Object Qpost_read_conversion, Qpre_write_conversion;
+static Lisp_Object Qdefault_char;
Lisp_Object Qno_conversion, Qundecided;
-Lisp_Object Qcharset, Qiso_2022, Qutf_8, Qutf_16, Qshift_jis, Qbig5;
-Lisp_Object Qbig, Qlittle;
-Lisp_Object Qcoding_system_history;
-Lisp_Object Qvalid_codes;
-Lisp_Object QCcategory, QCmnemonic, QCdefault_char;
-Lisp_Object QCdecode_translation_table, QCencode_translation_table;
-Lisp_Object QCpost_read_conversion, QCpre_write_conversion;
-Lisp_Object QCascii_compatible_p;
+Lisp_Object Qcharset, Qutf_8;
+static Lisp_Object Qiso_2022;
+static Lisp_Object Qutf_16, Qshift_jis, Qbig5;
+static Lisp_Object Qbig, Qlittle;
+static Lisp_Object Qcoding_system_history;
+static Lisp_Object Qvalid_codes;
+static Lisp_Object QCcategory, QCmnemonic, QCdefault_char;
+static Lisp_Object QCdecode_translation_table, QCencode_translation_table;
+static Lisp_Object QCpost_read_conversion, QCpre_write_conversion;
+static Lisp_Object QCascii_compatible_p;
Lisp_Object Qcall_process, Qcall_process_region;
Lisp_Object Qstart_process, Qopen_network_stream;
-Lisp_Object Qtarget_idx;
+static Lisp_Object Qtarget_idx;
-Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source;
-Lisp_Object Qinterrupted, Qinsufficient_memory;
+static Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source;
+static Lisp_Object Qinterrupted, Qinsufficient_memory;
/* If a symbol has this property, evaluate the value to define the
symbol as a coding system. */
Lisp_Object Qtranslation_table;
Lisp_Object Qtranslation_table_id;
-Lisp_Object Qtranslation_table_for_decode;
-Lisp_Object Qtranslation_table_for_encode;
+static Lisp_Object Qtranslation_table_for_decode;
+static Lisp_Object Qtranslation_table_for_encode;
/* Two special coding systems. */
-Lisp_Object Vsjis_coding_system;
-Lisp_Object Vbig5_coding_system;
+static Lisp_Object Vsjis_coding_system;
+static Lisp_Object Vbig5_coding_system;
/* ISO2022 section */
produced_chars++; \
if (multibytep) \
{ \
- int ch = (c); \
+ unsigned ch = (c); \
if (ch >= 0x80) \
ch = BYTE8_TO_CHAR (ch); \
CHAR_STRING_ADVANCE (ch, dst); \
produced_chars += 2; \
if (multibytep) \
{ \
- int ch; \
+ unsigned ch; \
\
ch = (c1); \
if (ch >= 0x80) \
EMACS_INT, unsigned char *);
static void setup_iso_safe_charsets (Lisp_Object);
static unsigned char *encode_designation_at_bol (struct coding_system *,
- int *, int *,
- unsigned char *);
+ int *, unsigned char *);
static int detect_eol (const unsigned char *,
EMACS_INT, enum coding_category);
static Lisp_Object adjust_coding_eol_type (struct coding_system *, int);
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
do { \
if (dst + (bytes) >= dst_end) \
{ \
- int more_bytes = charbuf_end - charbuf + (bytes); \
+ EMACS_INT more_bytes = charbuf_end - charbuf + (bytes); \
\
dst = alloc_destination (coding, more_bytes, dst); \
dst_end = coding->destination + coding->dst_bytes; \
static void
coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes)
{
+ if (coding->dst_bytes >= MOST_POSITIVE_FIXNUM - bytes)
+ error ("Maximum size of buffer or string exceeded");
coding->destination = (unsigned char *) xrealloc (coding->destination,
coding->dst_bytes + bytes);
coding->dst_bytes += bytes;
const unsigned char *src = coding->source, *src_base;
const unsigned char *src_end = coding->source + coding->src_bytes;
int multibytep = coding->src_multibyte;
- int consumed_chars = 0;
+ EMACS_INT consumed_chars = 0;
int bom_found = 0;
int found = 0;
const unsigned char *src_base;
int *charbuf = coding->charbuf + coding->charbuf_used;
int *charbuf_end = coding->charbuf + coding->charbuf_size;
- int consumed_chars = 0, consumed_chars_base = 0;
+ EMACS_INT consumed_chars = 0, consumed_chars_base = 0;
int multibytep = coding->src_multibyte;
enum utf_bom_type bom = CODING_UTF_8_BOM (coding);
- Lisp_Object attr, charset_list;
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
- CODING_GET_INFO (coding, attr, charset_list);
-
if (bom != utf_without_bom)
{
int c1, c2, c3;
int *charbuf_end = charbuf + coding->charbuf_used;
unsigned char *dst = coding->destination + coding->produced;
unsigned char *dst_end = coding->destination + coding->dst_bytes;
- int produced_chars = 0;
+ EMACS_INT produced_chars = 0;
int c;
if (CODING_UTF_8_BOM (coding) == utf_with_bom)
int *charbuf = coding->charbuf + coding->charbuf_used;
/* We may produces at most 3 chars in one loop. */
int *charbuf_end = coding->charbuf + coding->charbuf_size - 2;
- int consumed_chars = 0, consumed_chars_base = 0;
+ EMACS_INT consumed_chars = 0, consumed_chars_base = 0;
int multibytep = coding->src_multibyte;
enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding);
int surrogate = CODING_UTF_16_SURROGATE (coding);
- Lisp_Object attr, charset_list;
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr1 = -1, byte_after_cr2 = -1;
- CODING_GET_INFO (coding, attr, charset_list);
-
if (bom == utf_with_bom)
{
int c, c1, c2;
int safe_room = 8;
enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian;
- int produced_chars = 0;
- Lisp_Object attrs, charset_list;
+ EMACS_INT produced_chars = 0;
int c;
- CODING_GET_INFO (coding, attrs, charset_list);
-
if (bom != utf_without_bom)
{
ASSURE_DESTINATION (safe_room);
const unsigned char *src = coding->source, *src_base;
const unsigned char *src_end = coding->source + coding->src_bytes;
int multibytep = coding->src_multibyte;
- int consumed_chars = 0;
+ EMACS_INT consumed_chars = 0;
int c;
int found = 0;
/* 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);
- int consumed_chars = 0, consumed_chars_base;
+ = 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;
- Lisp_Object attrs, charset_list;
- int char_offset = coding->produced_char;
- int last_offset = char_offset;
+ EMACS_INT char_offset = coding->produced_char;
+ EMACS_INT last_offset = char_offset;
int last_id = charset_ascii;
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status;
- CODING_GET_INFO (coding, attrs, charset_list);
-
if (cmp_status->state != COMPOSING_NO)
{
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;
unsigned char *dst = coding->destination + coding->produced;
unsigned char *dst_end = coding->destination + coding->dst_bytes;
int safe_room = 8;
- int produced_chars = 0;
+ EMACS_INT produced_chars = 0;
Lisp_Object attrs, charset_list;
int c;
int preferred_charset_id = -1;
COMPOSITION_WITH_RULE_ALTCHARS:
ESC 4 ALTCHAR [ RULE ALTCHAR ] ESC 0 CHAR [ CHAR ] ESC 1 */
-enum iso_code_class_type iso_code_class[256];
+static enum iso_code_class_type iso_code_class[256];
#define SAFE_CHARSET_P(coding, id) \
((id) <= (coding)->max_charset_id \
int single_shifting = 0;
int id;
int c, c1;
- int consumed_chars = 0;
+ EMACS_INT consumed_chars = 0;
int i;
int rejected = 0;
int found = 0;
*/
/* Decode a composition rule C1 and maybe one more byte from the
- source, and set RULE to the encoded composition rule, NBYTES to the
- length of the composition rule. If the rule is invalid, set RULE
- to some negative value. */
+ source, and set RULE to the encoded composition rule. If the rule
+ is invalid, goto invalid_code. */
-#define DECODE_COMPOSITION_RULE(rule, nbytes) \
+#define DECODE_COMPOSITION_RULE(rule) \
do { \
rule = c1 - 32; \
if (rule < 0) \
- break; \
+ goto invalid_code; \
if (rule < 81) /* old format (before ver.21) */ \
{ \
int gref = (rule) / 9; \
if (gref == 4) gref = 10; \
if (nref == 4) nref = 10; \
rule = COMPOSITION_ENCODE_RULE (gref, nref); \
- nbytes = 1; \
} \
else /* new format (after ver.21) */ \
{ \
int b; \
\
ONE_MORE_BYTE (b); \
+ if (! COMPOSITION_ENCODE_RULE_VALID (rule - 81, b - 32)) \
+ goto invalid_code; \
rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \
- if (rule >= 0) \
- rule += 0x100; /* to destinguish it from the old format */ \
- nbytes = 2; \
+ rule += 0x100; /* Distinguish it from the old format. */ \
} \
} while (0)
loop and one more charset annotation at the end. */
int *charbuf_end
= coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3);
- int consumed_chars = 0, consumed_chars_base;
+ EMACS_INT consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
/* Charsets invoked to graphic plane 0 and 1 respectively. */
int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0);
struct charset *charset;
int c;
struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding);
- Lisp_Object attrs, charset_list;
- int char_offset = coding->produced_char;
- int last_offset = char_offset;
+ Lisp_Object attrs = CODING_ID_ATTRS (coding->id);
+ EMACS_INT char_offset = coding->produced_char;
+ EMACS_INT last_offset = char_offset;
int last_id = charset_ascii;
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
int i;
- CODING_GET_INFO (coding, attrs, charset_list);
setup_iso_safe_charsets (attrs);
- /* Charset list may have been changed. */
- charset_list = CODING_ATTR_CHARSET_LIST (attrs);
coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs));
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;
|| cmp_status->state == COMPOSING_COMPONENT_RULE)
&& c1 != ISO_CODE_ESC)
{
- int rule, nbytes;
+ int rule;
- DECODE_COMPOSITION_RULE (rule, nbytes);
- if (rule < 0)
- goto invalid_code;
+ DECODE_COMPOSITION_RULE (rule);
STORE_COMPOSITION_RULE (rule);
continue;
}
static unsigned char *
encode_invocation_designation (struct charset *charset,
struct coding_system *coding,
- unsigned char *dst, int *p_nchars)
+ unsigned char *dst, EMACS_INT *p_nchars)
{
int multibytep = coding->dst_multibyte;
- int produced_chars = *p_nchars;
+ EMACS_INT produced_chars = *p_nchars;
int reg; /* graphic register number */
int id = CHARSET_ID (charset);
static unsigned char *
encode_designation_at_bol (struct coding_system *coding, int *charbuf,
- int *charbuf_end, unsigned char *dst)
+ unsigned char *dst)
{
struct charset *charset;
/* Table of charsets to be designated to each graphic register. */
int r[4];
int c, found = 0, reg;
- int produced_chars = 0;
+ EMACS_INT produced_chars = 0;
int multibytep = coding->dst_multibyte;
Lisp_Object attrs;
Lisp_Object charset_list;
int bol_designation
= (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL
&& CODING_ISO_BOL (coding));
- int produced_chars = 0;
+ EMACS_INT produced_chars = 0;
Lisp_Object attrs, eol_type, charset_list;
int ascii_compatible;
int c;
unsigned char *dst_prev = dst;
/* We have to produce designation sequences if any now. */
- dst = encode_designation_at_bol (coding, charbuf, charbuf_end, dst);
+ dst = encode_designation_at_bol (coding, charbuf, dst);
bol_designation = 0;
/* We are sure that designation sequences are all ASCII bytes. */
produced_chars += dst - dst_prev;
const unsigned char *src = coding->source, *src_base;
const unsigned char *src_end = coding->source + coding->src_bytes;
int multibytep = coding->src_multibyte;
- int consumed_chars = 0;
+ EMACS_INT consumed_chars = 0;
int found = 0;
int c;
Lisp_Object attrs, charset_list;
const unsigned char *src = coding->source, *src_base;
const unsigned char *src_end = coding->source + coding->src_bytes;
int multibytep = coding->src_multibyte;
- int consumed_chars = 0;
+ EMACS_INT consumed_chars = 0;
int found = 0;
int c;
the end. */
int *charbuf_end
= coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
- int consumed_chars = 0, consumed_chars_base;
+ EMACS_INT consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
struct charset *charset_roman, *charset_kanji, *charset_kana;
struct charset *charset_kanji2;
Lisp_Object attrs, charset_list, val;
- int char_offset = coding->produced_char;
- int last_offset = char_offset;
+ EMACS_INT char_offset = coding->produced_char;
+ EMACS_INT last_offset = char_offset;
int last_id = charset_ascii;
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
the end. */
int *charbuf_end
= coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
- int consumed_chars = 0, consumed_chars_base;
+ EMACS_INT consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
struct charset *charset_roman, *charset_big5;
Lisp_Object attrs, charset_list, val;
- int char_offset = coding->produced_char;
- int last_offset = char_offset;
+ EMACS_INT char_offset = coding->produced_char;
+ EMACS_INT last_offset = char_offset;
int last_id = charset_ascii;
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
unsigned char *dst = coding->destination + coding->produced;
unsigned char *dst_end = coding->destination + coding->dst_bytes;
int safe_room = 4;
- int produced_chars = 0;
+ EMACS_INT produced_chars = 0;
Lisp_Object attrs, charset_list, val;
int ascii_compatible;
- struct charset *charset_roman, *charset_kanji, *charset_kana;
+ struct charset *charset_kanji, *charset_kana;
struct charset *charset_kanji2;
int c;
CODING_GET_INFO (coding, attrs, charset_list);
- val = charset_list;
- charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
+ val = XCDR (charset_list);
charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val)));
unsigned char *dst = coding->destination + coding->produced;
unsigned char *dst_end = coding->destination + coding->dst_bytes;
int safe_room = 4;
- int produced_chars = 0;
+ EMACS_INT produced_chars = 0;
Lisp_Object attrs, charset_list, val;
int ascii_compatible;
- struct charset *charset_roman, *charset_big5;
+ struct charset *charset_big5;
int c;
CODING_GET_INFO (coding, attrs, charset_list);
- val = charset_list;
- charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
+ val = XCDR (charset_list);
charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val)));
ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs));
const unsigned char *src = coding->source, *src_base;
const unsigned char *src_end = coding->source + coding->src_bytes;
int multibytep = coding->src_multibyte;
- int consumed_chars = 0;
+ EMACS_INT consumed_chars = 0;
int found = 0;
unsigned char *valids;
- int head_ascii = coding->head_ascii;
+ EMACS_INT head_ascii = coding->head_ascii;
Lisp_Object attrs;
detect_info->checked |= CATEGORY_MASK_CCL;
const unsigned char *src_end = coding->source + coding->src_bytes;
int *charbuf = coding->charbuf + coding->charbuf_used;
int *charbuf_end = coding->charbuf + coding->charbuf_size;
- int consumed_chars = 0;
+ EMACS_INT consumed_chars = 0;
int multibytep = coding->src_multibyte;
struct ccl_program *ccl = &coding->spec.ccl->ccl;
int source_charbuf[1024];
unsigned char *dst = coding->destination + coding->produced;
unsigned char *dst_end = coding->destination + coding->dst_bytes;
int destination_charbuf[1024];
- int i, produced_chars = 0;
+ EMACS_INT produced_chars = 0;
+ int i;
Lisp_Object attrs, charset_list;
CODING_GET_INFO (coding, attrs, charset_list);
int *charbuf_end = coding->charbuf + coding->charbuf_used;
unsigned char *dst = coding->destination + coding->produced;
unsigned char *dst_end = coding->destination + coding->dst_bytes;
- int produced_chars = 0;
+ EMACS_INT produced_chars = 0;
int c;
if (multibytep)
const unsigned char *src = coding->source, *src_base;
const unsigned char *src_end = coding->source + coding->src_bytes;
int multibytep = coding->src_multibyte;
- int consumed_chars = 0;
+ EMACS_INT consumed_chars = 0;
Lisp_Object attrs, valids, name;
int found = 0;
- int head_ascii = coding->head_ascii;
+ EMACS_INT head_ascii = coding->head_ascii;
int check_latin_extra = 0;
detect_info->checked |= CATEGORY_MASK_CHARSET;
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)
the end. */
int *charbuf_end
= coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
- int consumed_chars = 0, consumed_chars_base;
+ EMACS_INT consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
- Lisp_Object attrs, charset_list, valids;
- int char_offset = coding->produced_char;
- int last_offset = char_offset;
+ Lisp_Object attrs = CODING_ID_ATTRS (coding->id);
+ Lisp_Object valids;
+ EMACS_INT char_offset = coding->produced_char;
+ EMACS_INT last_offset = char_offset;
int last_id = charset_ascii;
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
- CODING_GET_INFO (coding, attrs, charset_list);
valids = AREF (attrs, coding_attr_charset_valids);
while (1)
unsigned char *dst = coding->destination + coding->produced;
unsigned char *dst_end = coding->destination + coding->dst_bytes;
int safe_room = MAX_MULTIBYTE_LENGTH;
- int produced_chars = 0;
+ EMACS_INT produced_chars = 0;
Lisp_Object attrs, charset_list;
int ascii_compatible;
int c;
system is detected, update fields of CODING by the detected coding
system. */
-void
+static void
detect_coding (struct coding_system *coding)
{
const unsigned char *src, *src_end;
}
else if (EQ (eol_type, Qdos))
{
- int n = 0;
+ EMACS_INT n = 0;
if (NILP (coding->dst_object))
{
}
else
{
- int pos_byte = coding->dst_pos_byte;
- int pos = coding->dst_pos;
- int pos_end = pos + coding->produced_char - 1;
+ EMACS_INT pos_byte = coding->dst_pos_byte;
+ EMACS_INT pos = coding->dst_pos;
+ EMACS_INT pos_end = pos + coding->produced_char - 1;
while (pos < pos_end)
{
if (c >= 0)
{
- int from_nchars = 1, to_nchars = 1;
+ EMACS_INT from_nchars = 1, to_nchars = 1;
Lisp_Object trans = Qnil;
LOOKUP_TRANSLATION_TABLE (translation_table, c, trans);
[ -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)
return coding->result;
}
-int
-encode_coding_gap (struct coding_system *coding,
- EMACS_INT chars, EMACS_INT bytes)
-{
- int count = SPECPDL_INDEX ();
-
- code_conversion_save (0, 0);
-
- coding->src_object = Fcurrent_buffer ();
- coding->src_chars = chars;
- coding->src_bytes = bytes;
- coding->src_pos = -chars;
- coding->src_pos_byte = -bytes;
- coding->src_multibyte = chars < bytes;
- coding->dst_object = coding->src_object;
- coding->dst_pos = PT;
- coding->dst_pos_byte = PT_BYTE;
-
- encode_coding (coding);
-
- unbind_to (count, Qnil);
- return coding->result;
-}
-
/* Decode the text in the range FROM/FROM_BYTE and TO/TO_BYTE in
SRC_OBJECT into DST_OBJECT by coding context CODING.
}
-static INLINE int
+static inline int
char_encodable_p (int c, Lisp_Object attrs)
{
Lisp_Object tail;
}
-Lisp_Object
+static Lisp_Object
code_convert_region (Lisp_Object start, Lisp_Object end,
Lisp_Object coding_system, Lisp_Object dst_object,
int encodep, int norecord)
{
Lisp_Object spec, attrs, val;
struct charset *charset_roman, *charset_kanji, *charset_kana, *charset;
+ EMACS_INT ch;
int c;
CHECK_NATNUM (code);
- c = XFASTINT (code);
+ ch = XFASTINT (code);
CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec);
attrs = AREF (spec, 0);
- if (ASCII_BYTE_P (c)
+ if (ASCII_BYTE_P (ch)
&& ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)))
return code;
charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val)));
- if (c <= 0x7F)
- charset = charset_roman;
- else if (c >= 0xA0 && c < 0xDF)
+ if (ch <= 0x7F)
{
+ c = ch;
+ charset = charset_roman;
+ }
+ else if (ch >= 0xA0 && ch < 0xDF)
+ {
+ c = ch - 0x80;
charset = charset_kana;
- c -= 0x80;
}
else
{
- int c1 = c >> 8, c2 = c & 0xFF;
+ EMACS_INT c1 = ch >> 8;
+ int c2 = ch & 0xFF;
if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF
|| c2 < 0x40 || c2 == 0x7F || c2 > 0xFC)
- error ("Invalid code: %d", code);
+ 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: %d", code);
+ 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);
{
Lisp_Object spec, attrs, val;
struct charset *charset_roman, *charset_big5, *charset;
+ EMACS_INT ch;
int c;
CHECK_NATNUM (code);
- c = XFASTINT (code);
+ ch = XFASTINT (code);
CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec);
attrs = AREF (spec, 0);
- if (ASCII_BYTE_P (c)
+ if (ASCII_BYTE_P (ch)
&& ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)))
return code;
charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val)));
- if (c <= 0x7F)
- charset = charset_roman;
+ if (ch <= 0x7F)
+ {
+ c = ch;
+ charset = charset_roman;
+ }
else
{
- int b1 = c >> 8, b2 = c & 0x7F;
+ EMACS_INT b1 = ch >> 8;
+ int b2 = ch & 0x7F;
if (b1 < 0xA1 || b1 > 0xFE
|| b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE)
- error ("Invalid code: %d", code);
+ error ("Invalid code: %"pI"d", ch);
+ c = ch;
charset = charset_big5;
}
- c = DECODE_CHAR (charset, (unsigned )c);
+ c = DECODE_CHAR (charset, c);
if (c < 0)
- error ("Invalid code: %d", code);
+ 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);
}
contents of BUFFER instead of reading the file.
usage: (find-operation-coding-system OPERATION ARGUMENTS...) */)
- (int nargs, Lisp_Object *args)
+ (size_t nargs, Lisp_Object *args)
{
Lisp_Object operation, target_idx, target, val;
register Lisp_Object chain;
error ("Too few arguments");
operation = args[0];
if (!SYMBOLP (operation)
- || !INTEGERP (target_idx = Fget (operation, Qtarget_idx)))
+ || !NATNUMP (target_idx = Fget (operation, Qtarget_idx)))
error ("Invalid first argument");
- if (nargs < 1 + XINT (target_idx))
- error ("Too few arguments for operation: %s",
+ if (nargs < 1 + XFASTINT (target_idx))
+ error ("Too few arguments for operation `%s'",
SDATA (SYMBOL_NAME (operation)));
- target = args[XINT (target_idx) + 1];
+ 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 %dth argument", XINT (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) */)
- (int nargs, Lisp_Object *args)
+ (size_t nargs, Lisp_Object *args)
{
- int i, j;
+ size_t i, j;
int changed[coding_category_max];
enum coding_category priorities[coding_category_max];
/* Update `coding-category-list'. */
Vcoding_category_list = Qnil;
- for (i = coding_category_max - 1; i >= 0; i--)
+ for (i = coding_category_max; i-- > 0; )
Vcoding_category_list
= Fcons (AREF (Vcoding_category_table, priorities[i]),
Vcoding_category_list);
Sdefine_coding_system_internal, coding_arg_max, MANY, 0,
doc: /* For internal use only.
usage: (define-coding-system-internal ...) */)
- (int nargs, Lisp_Object *args)
+ (size_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: %d", XINT (XCDR (val)));
+ error ("Invalid graphic register number: %"pI"d", XINT (XCDR (val)));
XSETCAR (val, make_number (id));
}