diff options
| author | Ken Raeburn <raeburn@raeburn.org> | 2015-11-01 01:42:21 -0400 |
|---|---|---|
| committer | Ken Raeburn <raeburn@raeburn.org> | 2015-11-01 01:42:21 -0400 |
| commit | 39372e1a1032521be74575bb06f95a3898fbae30 (patch) | |
| tree | 754bd242a23d2358ea116126fcb0a629947bd9ec /src/coding.c | |
| parent | 6a3121904d76e3b2f63007341d48c5c1af55de80 (diff) | |
| parent | e11aaee266da52937a3a031cb108fe13f68958c3 (diff) | |
| download | emacs-39372e1a1032521be74575bb06f95a3898fbae30.tar.gz | |
merge from trunk
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 522 |
1 files changed, 280 insertions, 242 deletions
diff --git a/src/coding.c b/src/coding.c index 5b637627763..0b42a36543c 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1,5 +1,5 @@ /* Coding system handler (conversion, detection, etc). - Copyright (C) 2001-2013 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 National Institute of Advanced Industrial Science and Technology (AIST) @@ -297,41 +297,10 @@ encode_coding_XXX (struct coding_system *coding) #include "ccl.h" #include "composite.h" #include "coding.h" -#include "window.h" -#include "frame.h" #include "termhooks.h" Lisp_Object Vcoding_system_hash_table; -static Lisp_Object Qcoding_system, Qeol_type; -static Lisp_Object Qcoding_aliases; -Lisp_Object Qunix, Qdos; -static Lisp_Object Qmac; -Lisp_Object Qbuffer_file_coding_system; -static Lisp_Object Qpost_read_conversion, Qpre_write_conversion; -static Lisp_Object Qdefault_char; -Lisp_Object Qno_conversion, Qundecided; -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; -static Lisp_Object Qtarget_idx; - -static Lisp_Object Qinsufficient_source, Qinvalid_source, Qinterrupted; - -/* If a symbol has this property, evaluate the value to define the - symbol as a coding system. */ -static Lisp_Object Qcoding_system_define_form; - /* Format of end-of-line decided by system. This is Qunix on Unix and Mac, Qdos on DOS/Windows. This has an effect only for external encoding (i.e. for output to @@ -340,17 +309,6 @@ static Lisp_Object system_eol_type; #ifdef emacs -Lisp_Object Qcoding_system_p, Qcoding_system_error; - -/* Coding system emacs-mule and raw-text are for converting only - end-of-line format. */ -Lisp_Object Qemacs_mule, Qraw_text; -Lisp_Object Qutf_8_emacs; - -#if defined (WINDOWSNT) || defined (CYGWIN) -static Lisp_Object Qutf_16le; -#endif - /* Coding-systems are handed between Emacs Lisp programs and C internal routines by the following three variables. */ /* Coding system to be used to encode text for terminal display when @@ -359,11 +317,6 @@ struct coding_system safe_terminal_coding; #endif /* emacs */ -Lisp_Object Qtranslation_table; -Lisp_Object Qtranslation_table_id; -static Lisp_Object Qtranslation_table_for_decode; -static Lisp_Object Qtranslation_table_for_encode; - /* Two special coding systems. */ static Lisp_Object Vsjis_coding_system; static Lisp_Object Vbig5_coding_system; @@ -395,7 +348,8 @@ static Lisp_Object Vbig5_coding_system; #define CODING_ISO_BOL(coding) \ ((coding)->spec.iso_2022.bol) #define CODING_ISO_INVOKED_CHARSET(coding, plane) \ - CODING_ISO_DESIGNATION ((coding), CODING_ISO_INVOCATION ((coding), (plane))) + (CODING_ISO_INVOCATION (coding, plane) < 0 ? -1 \ + : CODING_ISO_DESIGNATION (coding, CODING_ISO_INVOCATION (coding, plane))) #define CODING_ISO_CMP_STATUS(coding) \ (&(coding)->spec.iso_2022.cmp_status) #define CODING_ISO_EXTSEGMENT_LEN(coding) \ @@ -642,15 +596,6 @@ static enum coding_category coding_priorities[coding_category_max]; Nth coding category. */ static struct coding_system coding_categories[coding_category_max]; -/*** Commonly used macros and functions ***/ - -#ifndef min -#define min(a, b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef max -#define max(a, b) ((a) > (b) ? (a) : (b)) -#endif - /* Encode a flag that can be nil, something else, or t as -1, 0, 1. */ static int @@ -690,6 +635,14 @@ CHECK_NATNUM_CDR (Lisp_Object x) XSETCDR (x, tmp); } +/* True if CODING's destination can be grown. */ + +static bool +growable_destination (struct coding_system *coding) +{ + return STRINGP (coding->dst_object) || BUFFERP (coding->dst_object); +} + /* Safely get one byte from the source text pointed by SRC which ends at SRC_END, and set C to that byte. If there are not enough bytes @@ -1190,8 +1143,8 @@ alloc_destination (struct coding_system *coding, ptrdiff_t nbytes, #define UTF_8_BOM_2 0xBB #define UTF_8_BOM_3 0xBF -/* Unlike the other detect_coding_XXX, this function counts number of - characters and check EOL format. */ +/* Unlike the other detect_coding_XXX, this function counts the number + of characters and checks the EOL format. */ static bool detect_coding_utf_8 (struct coding_system *coding, @@ -1202,7 +1155,7 @@ detect_coding_utf_8 (struct coding_system *coding, bool multibytep = coding->src_multibyte; ptrdiff_t consumed_chars = 0; bool bom_found = 0; - int nchars = coding->head_ascii; + ptrdiff_t nchars = coding->head_ascii; int eol_seen = coding->eol_seen; detect_info->checked |= CATEGORY_MASK_UTF_8; @@ -1300,6 +1253,7 @@ detect_coding_utf_8 (struct coding_system *coding, means that we found a valid non-ASCII characters. */ detect_info->found |= CATEGORY_MASK_UTF_8_AUTO | CATEGORY_MASK_UTF_8_NOSIG; } + coding->detected_utf8_bytes = src_base - coding->source; coding->detected_utf8_chars = nchars; return 1; } @@ -1484,8 +1438,7 @@ decode_coding_utf_8 (struct coding_system *coding) src = src_base; consumed_chars = consumed_chars_base; ONE_MORE_BYTE (c); - *charbuf++ = ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); - coding->errors++; + *charbuf++ = ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); } no_more_source: @@ -1548,8 +1501,8 @@ encode_coding_utf_8 (struct coding_system *coding) *dst++ = CHAR_TO_BYTE8 (c); else CHAR_STRING_ADVANCE_NO_UNIFY (c, dst); - produced_chars++; } + produced_chars = dst - (coding->destination + coding->produced); } record_conversion_result (coding, CODING_RESULT_SUCCESS); coding->produced_char += produced_chars; @@ -1684,7 +1637,6 @@ decode_coding_utf_16 (struct coding_system *coding) /* The first two bytes are not BOM. Treat them as bytes for a normal character. */ src = src_base; - coding->errors++; } CODING_UTF_16_BOM (coding) = utf_without_bom; } @@ -1724,7 +1676,7 @@ decode_coding_utf_16 (struct coding_system *coding) ONE_MORE_BYTE (c2); if (c2 < 0) { - *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); + *charbuf++ = ASCII_CHAR_P (c1) ? c1 : BYTE8_TO_CHAR (c1); *charbuf++ = -c2; continue; } @@ -1741,7 +1693,6 @@ decode_coding_utf_16 (struct coding_system *coding) c1 = surrogate & 0xFF, c2 = surrogate >> 8; *charbuf++ = c1; *charbuf++ = c2; - coding->errors++; if (UTF_16_HIGH_SURROGATE_P (c)) CODING_UTF_16_SURROGATE (coding) = surrogate = c; else @@ -2013,7 +1964,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, int charset_ID; unsigned code; int c; - int consumed_chars = 0; + ptrdiff_t consumed_chars = 0; bool mseq_found = 0; ONE_MORE_BYTE (c); @@ -2107,7 +2058,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, case 1: code = c; - charset_ID = ASCII_BYTE_P (code) ? charset_ascii : charset_eight_bit; + charset_ID = ASCII_CHAR_P (code) ? charset_ascii : charset_eight_bit; break; default: @@ -2595,9 +2546,8 @@ decode_coding_emacs_mule (struct coding_system *coding) src = src_base; consumed_chars = consumed_chars_base; ONE_MORE_BYTE (c); - *charbuf++ = ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); + *charbuf++ = ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); char_offset++; - coding->errors++; } no_more_source: @@ -3077,8 +3027,13 @@ detect_coding_iso_2022 (struct coding_system *coding, ONE_MORE_BYTE (c1); if (c1 < ' ' || c1 >= 0x80 || (id = iso_charset_table[0][c >= ','][c1]) < 0) - /* Invalid designation sequence. Just ignore. */ - break; + { + /* Invalid designation sequence. Just ignore. */ + if (c1 >= 0x80) + rejected |= (CATEGORY_MASK_ISO_7BIT + | CATEGORY_MASK_ISO_7_ELSE); + break; + } } else if (c == '$') { @@ -3092,16 +3047,29 @@ detect_coding_iso_2022 (struct coding_system *coding, ONE_MORE_BYTE (c1); if (c1 < ' ' || c1 >= 0x80 || (id = iso_charset_table[1][c >= ','][c1]) < 0) - /* Invalid designation sequence. Just ignore. */ - break; + { + /* Invalid designation sequence. Just ignore. */ + if (c1 >= 0x80) + rejected |= (CATEGORY_MASK_ISO_7BIT + | CATEGORY_MASK_ISO_7_ELSE); + break; + } } else - /* Invalid designation sequence. Just ignore it. */ - break; + { + /* Invalid designation sequence. Just ignore it. */ + if (c >= 0x80) + rejected |= (CATEGORY_MASK_ISO_7BIT + | CATEGORY_MASK_ISO_7_ELSE); + break; + } } else { /* Invalid escape sequence. Just ignore it. */ + if (c >= 0x80) + rejected |= (CATEGORY_MASK_ISO_7BIT + | CATEGORY_MASK_ISO_7_ELSE); break; } @@ -3152,7 +3120,7 @@ detect_coding_iso_2022 (struct coding_system *coding, if (inhibit_iso_escape_detection) break; single_shifting = 0; - rejected |= CATEGORY_MASK_ISO_7BIT; + rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE; if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) & CODING_ISO_FLAG_SINGLE_SHIFT) { @@ -3179,9 +3147,9 @@ detect_coding_iso_2022 (struct coding_system *coding, single_shifting = 0; break; } + rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE; if (c >= 0xA0) { - rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE; found |= CATEGORY_MASK_ISO_8_1; /* Check the length of succeeding codes of the range 0xA0..0FF. If the byte length is even, we include @@ -3190,7 +3158,7 @@ detect_coding_iso_2022 (struct coding_system *coding, if (! single_shifting && ! (rejected & CATEGORY_MASK_ISO_8_2)) { - int len = 1; + ptrdiff_t len = 1; while (src < src_end) { src_base = src; @@ -3572,7 +3540,7 @@ decode_coding_iso_2022 (struct coding_system *coding) if (CODING_ISO_EXTSEGMENT_LEN (coding) > 0) { - *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); + *charbuf++ = ASCII_CHAR_P (c1) ? c1 : BYTE8_TO_CHAR (c1); char_offset++; CODING_ISO_EXTSEGMENT_LEN (coding)--; continue; @@ -3599,7 +3567,7 @@ decode_coding_iso_2022 (struct coding_system *coding) } else { - *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); + *charbuf++ = ASCII_CHAR_P (c1) ? c1 : BYTE8_TO_CHAR (c1); char_offset++; } continue; @@ -3973,7 +3941,7 @@ decode_coding_iso_2022 (struct coding_system *coding) MAYBE_FINISH_COMPOSITION (); for (; src_base < src; src_base++, char_offset++) { - if (ASCII_BYTE_P (*src_base)) + if (ASCII_CHAR_P (*src_base)) *charbuf++ = *src_base; else *charbuf++ = BYTE8_TO_CHAR (*src_base); @@ -4003,9 +3971,8 @@ decode_coding_iso_2022 (struct coding_system *coding) src = src_base; consumed_chars = consumed_chars_base; ONE_MORE_BYTE (c); - *charbuf++ = c < 0 ? -c : ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); + *charbuf++ = c < 0 ? -c : ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); char_offset++; - coding->errors++; /* Reset the invocation and designation status to the safest one; i.e. designate ASCII to the graphic register 0, and invoke that register to the graphic plane 0. This typically @@ -4326,6 +4293,9 @@ encode_invocation_designation (struct charset *charset, else ENCODE_LOCKING_SHIFT_3; break; + + default: + break; } } @@ -4456,7 +4426,7 @@ encode_coding_iso_2022 (struct coding_system *coding) { /* We have to produce designation sequences if any now. */ unsigned char desig_buf[16]; - int nbytes; + ptrdiff_t nbytes; ptrdiff_t offset; charset_map_loaded = 0; @@ -4836,7 +4806,6 @@ decode_coding_sjis (struct coding_system *coding) ONE_MORE_BYTE (c); *charbuf++ = c < 0 ? -c : BYTE8_TO_CHAR (c); char_offset++; - coding->errors++; } no_more_source: @@ -4932,7 +4901,6 @@ decode_coding_big5 (struct coding_system *coding) ONE_MORE_BYTE (c); *charbuf++ = c < 0 ? -c : BYTE8_TO_CHAR (c); char_offset++; - coding->errors++; } no_more_source: @@ -5199,7 +5167,7 @@ decode_coding_ccl (struct coding_system *coding) source_charbuf[i++] = *p++; if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) - ccl->last_block = 1; + ccl->last_block = true; /* As ccl_driver calls DECODE_CHAR, buffer may be relocated. */ charset_map_loaded = 0; ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf, @@ -5259,7 +5227,7 @@ encode_coding_ccl (struct coding_system *coding) CODING_GET_INFO (coding, attrs, charset_list); if (coding->consumed_char == coding->src_chars && coding->mode & CODING_MODE_LAST_BLOCK) - ccl->last_block = 1; + ccl->last_block = true; do { @@ -5639,9 +5607,8 @@ decode_coding_charset (struct coding_system *coding) src = src_base; consumed_chars = consumed_chars_base; ONE_MORE_BYTE (c); - *charbuf++ = c < 0 ? -c : ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); + *charbuf++ = c < 0 ? -c : ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); char_offset++; - coding->errors++; } no_more_source: @@ -5761,6 +5728,7 @@ setup_coding_system (Lisp_Object coding_system, struct coding_system *coding) coding->safe_charsets = SDATA (val); coding->default_char = XINT (CODING_ATTR_DEFAULT_CHAR (attrs)); coding->carryover_bytes = 0; + coding->raw_destination = 0; coding_type = CODING_ATTR_TYPE (attrs); if (EQ (coding_type, Qundecided)) @@ -6012,6 +5980,15 @@ raw_text_coding_system (Lisp_Object coding_system) : AREF (raw_text_eol_type, 2)); } +/* Return true if CODING corresponds to raw-text coding-system. */ + +bool +raw_text_coding_system_p (struct coding_system *coding) +{ + return (coding->decoder == decode_coding_raw_text + && coding->encoder == encode_coding_raw_text) ? true : false; +} + /* If CODING_SYSTEM doesn't specify end-of-line format, return one of the subsidiary that has the same eol-spec as PARENT (if it is not @@ -6025,6 +6002,8 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent) if (NILP (coding_system)) coding_system = Qraw_text; + else + CHECK_CODING_SYSTEM (coding_system); spec = CODING_SYSTEM_SPEC (coding_system); eol_type = AREF (spec, 2); if (VECTORP (eol_type)) @@ -6035,6 +6014,7 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent) { Lisp_Object parent_spec; + CHECK_CODING_SYSTEM (parent); parent_spec = CODING_SYSTEM_SPEC (parent); parent_eol_type = AREF (parent_spec, 2); if (VECTORP (parent_eol_type)) @@ -6210,7 +6190,7 @@ static Lisp_Object adjust_coding_eol_type (struct coding_system *coding, EOL_SEEN_LF, EOL_SEEN_CR, and EOL_SEEN_CRLF, but the value is reliable only when all the source bytes are ASCII. */ -static int +static ptrdiff_t check_ascii (struct coding_system *coding) { const unsigned char *src, *end; @@ -6282,12 +6262,12 @@ check_ascii (struct coding_system *coding) the value is reliable only when all the source bytes are valid UTF-8. */ -static int +static ptrdiff_t check_utf_8 (struct coding_system *coding) { const unsigned char *src, *end; int eol_seen; - int nchars = coding->head_ascii; + ptrdiff_t nchars = coding->head_ascii; if (coding->head_ascii < 0) check_ascii (coding); @@ -6873,6 +6853,11 @@ decode_eol (struct coding_system *coding) } +/* MAX_LOOKUP's maximum value. MAX_LOOKUP is an int and so cannot + exceed INT_MAX. Also, MAX_LOOKUP is multiplied by sizeof (int) for + alloca, so it cannot exceed MAX_ALLOCA / sizeof (int). */ +enum { MAX_LOOKUP_MAX = min (INT_MAX, MAX_ALLOCA / sizeof (int)) }; + /* Return a translation table (or list of them) from coding system attribute vector ATTRS for encoding (if ENCODEP) or decoding (if not ENCODEP). */ @@ -6925,7 +6910,7 @@ get_translation_table (Lisp_Object attrs, bool encodep, int *max_lookup) { val = XCHAR_TABLE (translation_table)->extras[1]; if (NATNUMP (val) && *max_lookup < XFASTINT (val)) - *max_lookup = XFASTINT (val); + *max_lookup = min (XFASTINT (val), MAX_LOOKUP_MAX); } else if (CONSP (translation_table)) { @@ -6937,7 +6922,7 @@ get_translation_table (Lisp_Object attrs, bool encodep, int *max_lookup) { Lisp_Object tailval = XCHAR_TABLE (XCAR (tail))->extras[1]; if (NATNUMP (tailval) && *max_lookup < XFASTINT (tailval)) - *max_lookup = XFASTINT (tailval); + *max_lookup = min (XFASTINT (tailval), MAX_LOOKUP_MAX); } } } @@ -7020,8 +7005,10 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, int *buf = coding->charbuf; int *buf_end = buf + coding->charbuf_used; - if (EQ (coding->src_object, coding->dst_object)) + if (EQ (coding->src_object, coding->dst_object) + && ! NILP (coding->dst_object)) { + eassert (growable_destination (coding)); coding_set_source (coding); dst_end = ((unsigned char *) coding->source) + coding->consumed; } @@ -7060,6 +7047,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, if ((dst_end - dst) / MAX_MULTIBYTE_LENGTH < to_nchars) { + eassert (growable_destination (coding)); if (((min (PTRDIFF_MAX, SIZE_MAX) - (buf_end - buf)) / MAX_MULTIBYTE_LENGTH) < to_nchars) @@ -7104,7 +7092,10 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, const unsigned char *src_end = src + coding->consumed; if (EQ (coding->dst_object, coding->src_object)) - dst_end = (unsigned char *) src; + { + eassert (growable_destination (coding)); + dst_end = (unsigned char *) src; + } if (coding->src_multibyte != coding->dst_multibyte) { if (coding->src_multibyte) @@ -7120,6 +7111,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, ONE_MORE_BYTE (c); if (dst == dst_end) { + eassert (growable_destination (coding)); if (EQ (coding->src_object, coding->dst_object)) dst_end = (unsigned char *) src; if (dst == dst_end) @@ -7150,6 +7142,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, if (dst >= dst_end - 1) { + eassert (growable_destination (coding)); if (EQ (coding->src_object, coding->dst_object)) dst_end = (unsigned char *) src; if (dst >= dst_end - 1) @@ -7263,16 +7256,20 @@ produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos) coding->dst_object); } +#define MAX_CHARBUF_SIZE 0x4000 +/* How many units decoding functions expect in coding->charbuf at + most. Currently, decode_coding_emacs_mule expects the following + size, and that is the largest value. */ +#define MAX_CHARBUF_EXTRA_SIZE ((MAX_ANNOTATION_LENGTH * 3) + 1) -#define CHARBUF_SIZE 0x4000 - -#define ALLOC_CONVERSION_WORK_AREA(coding) \ - do { \ - coding->charbuf = SAFE_ALLOCA (CHARBUF_SIZE * sizeof (int)); \ - coding->charbuf_size = CHARBUF_SIZE; \ +#define ALLOC_CONVERSION_WORK_AREA(coding, size) \ + do { \ + ptrdiff_t units = min ((size) + MAX_CHARBUF_EXTRA_SIZE, \ + MAX_CHARBUF_SIZE); \ + coding->charbuf = SAFE_ALLOCA (units * sizeof (int)); \ + coding->charbuf_size = units; \ } while (0) - static void produce_annotation (struct coding_system *coding, ptrdiff_t pos) { @@ -7299,6 +7296,8 @@ produce_annotation (struct coding_system *coding, ptrdiff_t pos) case CODING_ANNOTATE_CHARSET_MASK: produce_charset (coding, charbuf, pos); break; + default: + break; } charbuf += len; } @@ -7369,9 +7368,8 @@ decode_coding (struct coding_system *coding) coding->produced = coding->produced_char = 0; coding->chars_at_source = 0; record_conversion_result (coding, CODING_RESULT_SUCCESS); - coding->errors = 0; - ALLOC_CONVERSION_WORK_AREA (coding); + ALLOC_CONVERSION_WORK_AREA (coding, coding->src_bytes); attrs = CODING_ID_ATTRS (coding->id); translation_table = get_translation_table (attrs, 0, NULL); @@ -7413,7 +7411,7 @@ decode_coding (struct coding_system *coding) coding->carryover_bytes = 0; if (coding->consumed < coding->src_bytes) { - int nbytes = coding->src_bytes - coding->consumed; + ptrdiff_t nbytes = coding->src_bytes - coding->consumed; const unsigned char *src; coding_set_source (coding); @@ -7765,9 +7763,8 @@ encode_coding (struct coding_system *coding) coding->consumed = coding->consumed_char = 0; coding->produced = coding->produced_char = 0; record_conversion_result (coding, CODING_RESULT_SUCCESS); - coding->errors = 0; - ALLOC_CONVERSION_WORK_AREA (coding); + ALLOC_CONVERSION_WORK_AREA (coding, coding->src_chars); if (coding->encoder == encode_coding_ccl) { @@ -7842,9 +7839,7 @@ static void code_conversion_restore (Lisp_Object arg) { Lisp_Object current, workbuf; - struct gcpro gcpro1; - GCPRO1 (arg); current = XCAR (arg); workbuf = XCDR (arg); if (! NILP (workbuf)) @@ -7855,7 +7850,6 @@ code_conversion_restore (Lisp_Object arg) Fkill_buffer (workbuf); } set_buffer_internal (XBUFFER (current)); - UNGCPRO; } Lisp_Object @@ -7889,7 +7883,7 @@ decode_coding_gap (struct coding_system *coding, coding->dst_multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); coding->head_ascii = -1; - coding->detected_utf8_chars = -1; + coding->detected_utf8_bytes = coding->detected_utf8_chars = -1; coding->eol_seen = EOL_SEEN_NONE; if (CODING_REQUIRE_DETECTION (coding)) detect_coding (coding); @@ -7906,7 +7900,8 @@ decode_coding_gap (struct coding_system *coding, if (chars != bytes) { /* There exists a non-ASCII byte. */ - if (EQ (CODING_ATTR_TYPE (attrs), Qutf_8)) + if (EQ (CODING_ATTR_TYPE (attrs), Qutf_8) + && coding->detected_utf8_bytes == coding->src_bytes) { if (coding->detected_utf8_chars >= 0) chars = coding->detected_utf8_chars; @@ -8126,16 +8121,12 @@ decode_coding_object (struct coding_system *coding, if (! NILP (CODING_ATTR_POST_READ (attrs))) { - struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE; Lisp_Object val; TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); - GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object, - old_deactivate_mark); val = safe_call1 (CODING_ATTR_POST_READ (attrs), make_number (coding->produced_char)); - UNGCPRO; CHECK_NATNUM (val); coding->produced_char += Z - prev_Z; coding->produced += Z_BYTE - prev_Z_BYTE; @@ -8263,15 +8254,8 @@ encode_coding_object (struct coding_system *coding, set_buffer_internal (XBUFFER (coding->src_object)); } - { - struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; - - GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object, - old_deactivate_mark); - safe_call2 (CODING_ATTR_PRE_WRITE (attrs), - make_number (BEG), make_number (Z)); - UNGCPRO; - } + safe_call2 (CODING_ATTR_PRE_WRITE (attrs), + make_number (BEG), make_number (Z)); if (XBUFFER (coding->src_object) != current_buffer) kill_src_buffer = 1; coding->src_object = Fcurrent_buffer (); @@ -8309,7 +8293,11 @@ encode_coding_object (struct coding_system *coding, } } else - code_conversion_save (0, 0); + { + code_conversion_save (0, 0); + coding->src_pos = from; + coding->src_pos_byte = from_byte; + } if (BUFFERP (dst_object)) { @@ -8352,6 +8340,11 @@ encode_coding_object (struct coding_system *coding, { if (BUFFERP (coding->dst_object)) coding->dst_object = Fbuffer_string (); + else if (coding->raw_destination) + /* This is used to avoid creating huge Lisp string. + NOTE: caller who sets `raw_destination' is also + responsible for freeing `destination' buffer. */ + coding->dst_object = Qnil; else { coding->dst_object @@ -8435,11 +8428,11 @@ from_unicode (Lisp_Object str) } Lisp_Object -from_unicode_buffer (const wchar_t* wstr) +from_unicode_buffer (const wchar_t *wstr) { return from_unicode ( make_unibyte_string ( - (char*) wstr, + (char *) wstr, /* we get one of the two final 0 bytes for free. */ 1 + sizeof (wchar_t) * wcslen (wstr))); } @@ -9023,13 +9016,13 @@ DEFUN ("find-coding-systems-region-internal", p = pbeg = BYTE_POS_ADDR (start_byte); pend = p + (end_byte - start_byte); - while (p < pend && ASCII_BYTE_P (*p)) p++; - while (p < pend && ASCII_BYTE_P (*(pend - 1))) pend--; + while (p < pend && ASCII_CHAR_P (*p)) p++; + while (p < pend && ASCII_CHAR_P (*(pend - 1))) pend--; work_table = Fmake_char_table (Qnil, Qnil); while (p < pend) { - if (ASCII_BYTE_P (*p)) + if (ASCII_CHAR_P (*p)) p++; else { @@ -9083,8 +9076,7 @@ DEFUN ("find-coding-systems-region-internal", DEFUN ("unencodable-char-position", Funencodable_char_position, Sunencodable_char_position, 3, 5, 0, - doc: /* -Return position of first un-encodable character in a region. + doc: /* Return position of first un-encodable character in a region. START and END specify the region and CODING-SYSTEM specifies the encoding to check. Return nil if CODING-SYSTEM does encode the region. @@ -9094,8 +9086,9 @@ list of positions. If optional 5th argument STRING is non-nil, it is a string to search for un-encodable characters. In that case, START and END are indexes -to the string. */) - (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object count, Lisp_Object string) +to the string and treated as in `substring'. */) + (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, + Lisp_Object count, Lisp_Object string) { EMACS_INT n; struct coding_system coding; @@ -9132,12 +9125,7 @@ to the string. */) else { CHECK_STRING (string); - CHECK_NATNUM (start); - CHECK_NATNUM (end); - if (! (XINT (start) <= XINT (end) && XINT (end) <= SCHARS (string))) - args_out_of_range_3 (string, start, end); - from = XINT (start); - to = XINT (end); + validate_subarray (string, start, end, SCHARS (string), &from, &to); if (! STRING_MULTIBYTE (string)) return Qnil; p = SDATA (string) + string_char_to_byte (string, from); @@ -9161,7 +9149,7 @@ to the string. */) int c; if (ascii_compatible) - while (p < stop && ASCII_BYTE_P (*p)) + while (p < stop && ASCII_CHAR_P (*p)) p++, from++; if (p >= stop) { @@ -9277,12 +9265,12 @@ is nil. */) p = pbeg = BYTE_POS_ADDR (start_byte); pend = p + (end_byte - start_byte); - while (p < pend && ASCII_BYTE_P (*p)) p++, pos++; - while (p < pend && ASCII_BYTE_P (*(pend - 1))) pend--; + while (p < pend && ASCII_CHAR_P (*p)) p++, pos++; + while (p < pend && ASCII_CHAR_P (*(pend - 1))) pend--; while (p < pend) { - if (ASCII_BYTE_P (*p)) + if (ASCII_CHAR_P (*p)) p++; else { @@ -9352,6 +9340,14 @@ code_convert_region (Lisp_Object start, Lisp_Object end, setup_coding_system (coding_system, &coding); coding.mode |= CODING_MODE_LAST_BLOCK; + if (BUFFERP (dst_object) && !EQ (dst_object, src_object)) + { + struct buffer *buf = XBUFFER (dst_object); + ptrdiff_t buf_pt = BUF_PT (buf); + + invalidate_buffer_caches (buf, buf_pt, buf_pt); + } + if (encodep) encode_coding_object (&coding, src_object, from, from_byte, to, to_byte, dst_object); @@ -9441,6 +9437,15 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system, coding.mode |= CODING_MODE_LAST_BLOCK; chars = SCHARS (string); bytes = SBYTES (string); + + if (BUFFERP (dst_object)) + { + struct buffer *buf = XBUFFER (dst_object); + ptrdiff_t buf_pt = BUF_PT (buf); + + invalidate_buffer_caches (buf, buf_pt, buf_pt); + } + if (encodep) encode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); else @@ -9467,6 +9472,55 @@ code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, return code_convert_string (string, coding_system, Qt, encodep, 0, 1); } +/* Encode or decode a file name, to or from a unibyte string suitable + for passing to C library functions. */ +Lisp_Object +decode_file_name (Lisp_Object fname) +{ +#ifdef WINDOWSNT + /* The w32 build pretends to use UTF-8 for file-name encoding, and + converts the file names either to UTF-16LE or to the system ANSI + codepage internally, depending on the underlying OS; see w32.c. */ + if (! NILP (Fcoding_system_p (Qutf_8))) + return code_convert_string_norecord (fname, Qutf_8, 0); + return fname; +#else /* !WINDOWSNT */ + if (! NILP (Vfile_name_coding_system)) + return code_convert_string_norecord (fname, Vfile_name_coding_system, 0); + else if (! NILP (Vdefault_file_name_coding_system)) + return code_convert_string_norecord (fname, + Vdefault_file_name_coding_system, 0); + else + return fname; +#endif +} + +Lisp_Object +encode_file_name (Lisp_Object fname) +{ + /* This is especially important during bootstrap and dumping, when + file-name encoding is not yet known, and therefore any non-ASCII + file names are unibyte strings, and could only be thrashed if we + try to encode them. */ + if (!STRING_MULTIBYTE (fname)) + return fname; +#ifdef WINDOWSNT + /* The w32 build pretends to use UTF-8 for file-name encoding, and + converts the file names either to UTF-16LE or to the system ANSI + codepage internally, depending on the underlying OS; see w32.c. */ + if (! NILP (Fcoding_system_p (Qutf_8))) + return code_convert_string_norecord (fname, Qutf_8, 1); + return fname; +#else /* !WINDOWSNT */ + if (! NILP (Vfile_name_coding_system)) + return code_convert_string_norecord (fname, Vfile_name_coding_system, 1); + else if (! NILP (Vdefault_file_name_coding_system)) + return code_convert_string_norecord (fname, + Vdefault_file_name_coding_system, 1); + else + return fname; +#endif +} DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, 2, 4, 0, @@ -9524,7 +9578,7 @@ Return the corresponding character. */) CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); attrs = AREF (spec, 0); - if (ASCII_BYTE_P (ch) + if (ASCII_CHAR_P (ch) && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) return code; @@ -9605,7 +9659,7 @@ Return the corresponding character. */) CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); attrs = AREF (spec, 0); - if (ASCII_BYTE_P (ch) + if (ASCII_CHAR_P (ch) && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) return code; @@ -9666,7 +9720,7 @@ DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_intern doc: /* Internal use only. */) (Lisp_Object coding_system, Lisp_Object terminal) { - struct terminal *term = get_terminal (terminal, 1); + struct terminal *term = decode_live_terminal (terminal); struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (term); CHECK_SYMBOL (coding_system); setup_coding_system (Fcheck_coding_system (coding_system), terminal_coding); @@ -9707,7 +9761,7 @@ frame's terminal device. */) (Lisp_Object terminal) { struct coding_system *terminal_coding - = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1)); + = TERMINAL_TERMINAL_CODING (decode_live_terminal (terminal)); Lisp_Object coding_system = CODING_ID_NAME (terminal_coding->id); /* For backward compatibility, return nil if it is `undecided'. */ @@ -9719,7 +9773,7 @@ DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_intern doc: /* Internal use only. */) (Lisp_Object coding_system, Lisp_Object terminal) { - struct terminal *t = get_terminal (terminal, 1); + struct terminal *t = decode_live_terminal (terminal); CHECK_SYMBOL (coding_system); if (NILP (coding_system)) coding_system = Qno_conversion; @@ -9738,7 +9792,7 @@ DEFUN ("keyboard-coding-system", (Lisp_Object terminal) { return CODING_ID_NAME (TERMINAL_KEYBOARD_CODING - (get_terminal (terminal, 1))->id); + (decode_live_terminal (terminal))->id); } @@ -9747,7 +9801,7 @@ DEFUN ("find-operation-coding-system", Ffind_operation_coding_system, 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). DECODING-SYSTEM is the coding system to use for decoding -\(in case OPERATION does decoding), and ENCODING-SYSTEM is the coding system +(in case OPERATION does decoding), and ENCODING-SYSTEM is the coding system for encoding (in case OPERATION does encoding). The first argument OPERATION specifies an I/O primitive: @@ -9948,7 +10002,8 @@ make_subsidiaries (Lisp_Object base) { Lisp_Object subsidiaries; ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base)); - char *buf = alloca (base_name_len + 6); + USE_SAFE_ALLOCA; + char *buf = SAFE_ALLOCA (base_name_len + 6); int i; memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); @@ -9958,6 +10013,7 @@ make_subsidiaries (Lisp_Object base) strcpy (buf + base_name_len, suffixes[i]); ASET (subsidiaries, i, intern (buf)); } + SAFE_FREE (); return subsidiaries; } @@ -10621,7 +10677,7 @@ Any alias or subsidiary coding system is not a base coding system. */) DEFUN ("coding-system-plist", Fcoding_system_plist, Scoding_system_plist, 1, 1, 0, - doc: "Return the property list of CODING-SYSTEM.") + doc: /* Return the property list of CODING-SYSTEM. */) (Lisp_Object coding_system) { Lisp_Object spec, attrs; @@ -10726,12 +10782,7 @@ void syms_of_coding (void) { staticpro (&Vcoding_system_hash_table); - { - Lisp_Object args[2]; - args[0] = QCtest; - args[1] = Qeq; - Vcoding_system_hash_table = Fmake_hash_table (2, args); - } + Vcoding_system_hash_table = CALLN (Fmake_hash_table, QCtest, Qeq); staticpro (&Vsjis_coding_system); Vsjis_coding_system = Qnil; @@ -10773,18 +10824,11 @@ syms_of_coding (void) /* Target SERVICE is the fourth argument. */ Fput (Qopen_network_stream, Qtarget_idx, make_number (3)); - DEFSYM (Qcoding_system, "coding-system"); - DEFSYM (Qcoding_aliases, "coding-aliases"); - - DEFSYM (Qeol_type, "eol-type"); DEFSYM (Qunix, "unix"); DEFSYM (Qdos, "dos"); DEFSYM (Qmac, "mac"); DEFSYM (Qbuffer_file_coding_system, "buffer-file-coding-system"); - DEFSYM (Qpost_read_conversion, "post-read-conversion"); - DEFSYM (Qpre_write_conversion, "pre-write-conversion"); - DEFSYM (Qdefault_char, "default-char"); DEFSYM (Qundecided, "undecided"); DEFSYM (Qno_conversion, "no-conversion"); DEFSYM (Qraw_text, "raw-text"); @@ -10808,25 +10852,19 @@ syms_of_coding (void) DEFSYM (Qcoding_system_p, "coding-system-p"); + /* Error signaled when there's a problem with detecting a coding system. */ DEFSYM (Qcoding_system_error, "coding-system-error"); Fput (Qcoding_system_error, Qerror_conditions, listn (CONSTYPE_PURE, 2, Qcoding_system_error, Qerror)); Fput (Qcoding_system_error, Qerror_message, build_pure_c_string ("Invalid coding system")); - /* Intern this now in case it isn't already done. - Setting this variable twice is harmless. - But don't staticpro it here--that is done in alloc.c. */ - Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots"); - DEFSYM (Qtranslation_table, "translation-table"); Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (2)); DEFSYM (Qtranslation_table_id, "translation-table-id"); - DEFSYM (Qtranslation_table_for_decode, "translation-table-for-decode"); - DEFSYM (Qtranslation_table_for_encode, "translation-table-for-encode"); - - DEFSYM (Qvalid_codes, "valid-codes"); + /* Coding system emacs-mule and raw-text are for converting only + end-of-line format. */ DEFSYM (Qemacs_mule, "emacs-mule"); DEFSYM (QCcategory, ":category"); @@ -10889,6 +10927,9 @@ syms_of_coding (void) DEFSYM (Qinsufficient_source, "insufficient-source"); DEFSYM (Qinvalid_source, "invalid-source"); DEFSYM (Qinterrupted, "interrupted"); + + /* If a symbol has this property, evaluate the value to define the + symbol as a coding system. */ DEFSYM (Qcoding_system_define_form, "coding-system-define-form"); defsubr (&Scoding_system_p); @@ -11008,7 +11049,7 @@ conversion. */); DEFVAR_BOOL ("inhibit-eol-conversion", inhibit_eol_conversion, doc: /* -*Non-nil means always inhibit code conversion of end-of-line format. +Non-nil means always inhibit code conversion of end-of-line format. See info node `Coding Systems' and info node `Text and Binary' concerning such conversion. */); inhibit_eol_conversion = 0; @@ -11076,33 +11117,34 @@ See also the function `find-operation-coding-system'. */); DEFVAR_LISP ("locale-coding-system", Vlocale_coding_system, doc: /* Coding system to use with system messages. -Also used for decoding keyboard input on X Window system. */); +Also used for decoding keyboard input on X Window system, and for +encoding standard output and error streams. */); Vlocale_coding_system = Qnil; /* The eol mnemonics are reset in startup.el system-dependently. */ DEFVAR_LISP ("eol-mnemonic-unix", eol_mnemonic_unix, doc: /* -*String displayed in mode line for UNIX-like (LF) end-of-line format. */); +String displayed in mode line for UNIX-like (LF) end-of-line format. */); eol_mnemonic_unix = build_pure_c_string (":"); DEFVAR_LISP ("eol-mnemonic-dos", eol_mnemonic_dos, doc: /* -*String displayed in mode line for DOS-like (CRLF) end-of-line format. */); +String displayed in mode line for DOS-like (CRLF) end-of-line format. */); eol_mnemonic_dos = build_pure_c_string ("\\"); DEFVAR_LISP ("eol-mnemonic-mac", eol_mnemonic_mac, doc: /* -*String displayed in mode line for MAC-like (CR) end-of-line format. */); +String displayed in mode line for MAC-like (CR) end-of-line format. */); eol_mnemonic_mac = build_pure_c_string ("/"); DEFVAR_LISP ("eol-mnemonic-undecided", eol_mnemonic_undecided, doc: /* -*String displayed in mode line when end-of-line format is not yet determined. */); +String displayed in mode line when end-of-line format is not yet determined. */); eol_mnemonic_undecided = build_pure_c_string (":"); DEFVAR_LISP ("enable-character-translation", Venable_character_translation, doc: /* -*Non-nil enables character translation while encoding and decoding. */); +Non-nil enables character translation while encoding and decoding. */); Venable_character_translation = Qt; DEFVAR_LISP ("standard-translation-table-for-decode", @@ -11134,7 +11176,7 @@ the cdr part is used for encoding a text to be sent to a process. */); Table of extra Latin codes in the range 128..159 (inclusive). This is a vector of length 256. If Nth element is non-nil, the existence of code N in a file -\(or output of subprocess) doesn't prevent it to be detected as +(or output of subprocess) doesn't prevent it to be detected as a coding system of ISO 2022 variant which has a flag `accept-latin-extra-code' t (e.g. iso-latin-1) on reading a file or reading output of a subprocess. @@ -11207,7 +11249,7 @@ decode text as usual. */); DEFVAR_BOOL ("disable-ascii-optimization", disable_ascii_optimization, doc: /* If non-nil, Emacs does not optimize code decoder for ASCII files. -Internal use only. Removed after the experimental optimizer gets stable. */); +Internal use only. Remove after the experimental optimizer becomes stable. */); disable_ascii_optimization = 0; DEFVAR_LISP ("translation-table-for-input", Vtranslation_table_for_input, @@ -11218,63 +11260,59 @@ See also `keyboard-translate-table'. Use of this variable for character code unification was rendered obsolete in Emacs 23.1 and later, since Unicode is now the basis of internal character representation. */); - Vtranslation_table_for_input = Qnil; - - { - Lisp_Object args[coding_arg_undecided_max]; - Lisp_Object plist[16]; - int i; - - for (i = 0; i < coding_arg_undecided_max; i++) - args[i] = Qnil; - - plist[0] = intern_c_string (":name"); - plist[1] = args[coding_arg_name] = Qno_conversion; - plist[2] = intern_c_string (":mnemonic"); - plist[3] = args[coding_arg_mnemonic] = make_number ('='); - plist[4] = intern_c_string (":coding-type"); - plist[5] = args[coding_arg_coding_type] = Qraw_text; - plist[6] = intern_c_string (":ascii-compatible-p"); - plist[7] = args[coding_arg_ascii_compatible_p] = Qt; - plist[8] = intern_c_string (":default-char"); - plist[9] = args[coding_arg_default_char] = make_number (0); - plist[10] = intern_c_string (":for-unibyte"); - plist[11] = args[coding_arg_for_unibyte] = Qt; - plist[12] = intern_c_string (":docstring"); - plist[13] = build_pure_c_string ("Do no conversion.\n\ -\n\ -When you visit a file with this coding, the file is read into a\n\ -unibyte buffer as is, thus each byte of a file is treated as a\n\ -character."); - plist[14] = intern_c_string (":eol-type"); - plist[15] = args[coding_arg_eol_type] = Qunix; - args[coding_arg_plist] = Flist (16, plist); - Fdefine_coding_system_internal (coding_arg_max, args); - - plist[1] = args[coding_arg_name] = Qundecided; - plist[3] = args[coding_arg_mnemonic] = make_number ('-'); - plist[5] = args[coding_arg_coding_type] = Qundecided; - /* This is already set. - plist[7] = args[coding_arg_ascii_compatible_p] = Qt; */ - plist[8] = intern_c_string (":charset-list"); - plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil); - plist[11] = args[coding_arg_for_unibyte] = Qnil; - plist[13] = build_pure_c_string ("No conversion on encoding, automatic conversion on decoding."); - plist[15] = args[coding_arg_eol_type] = Qnil; - args[coding_arg_plist] = Flist (16, plist); - args[coding_arg_undecided_inhibit_null_byte_detection] = make_number (0); - args[coding_arg_undecided_inhibit_iso_escape_detection] = make_number (0); - Fdefine_coding_system_internal (coding_arg_undecided_max, args); - } + Vtranslation_table_for_input = Qnil; + + Lisp_Object args[coding_arg_undecided_max]; + memclear (args, sizeof args); + + Lisp_Object plist[] = + { + QCname, + args[coding_arg_name] = Qno_conversion, + QCmnemonic, + args[coding_arg_mnemonic] = make_number ('='), + intern_c_string (":coding-type"), + args[coding_arg_coding_type] = Qraw_text, + QCascii_compatible_p, + args[coding_arg_ascii_compatible_p] = Qt, + QCdefault_char, + args[coding_arg_default_char] = make_number (0), + intern_c_string (":for-unibyte"), + args[coding_arg_for_unibyte] = Qt, + intern_c_string (":docstring"), + (build_pure_c_string + ("Do no conversion.\n" + "\n" + "When you visit a file with this coding, the file is read into a\n" + "unibyte buffer as is, thus each byte of a file is treated as a\n" + "character.")), + intern_c_string (":eol-type"), + args[coding_arg_eol_type] = Qunix, + }; + args[coding_arg_plist] = CALLMANY (Flist, plist); + Fdefine_coding_system_internal (coding_arg_max, args); + + plist[1] = args[coding_arg_name] = Qundecided; + plist[3] = args[coding_arg_mnemonic] = make_number ('-'); + plist[5] = args[coding_arg_coding_type] = Qundecided; + /* This is already set. + plist[7] = args[coding_arg_ascii_compatible_p] = Qt; */ + plist[8] = intern_c_string (":charset-list"); + plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil); + plist[11] = args[coding_arg_for_unibyte] = Qnil; + plist[13] = build_pure_c_string ("No conversion on encoding, " + "automatic conversion on decoding."); + plist[15] = args[coding_arg_eol_type] = Qnil; + args[coding_arg_plist] = CALLMANY (Flist, plist); + args[coding_arg_undecided_inhibit_null_byte_detection] = make_number (0); + args[coding_arg_undecided_inhibit_iso_escape_detection] = make_number (0); + Fdefine_coding_system_internal (coding_arg_undecided_max, args); setup_coding_system (Qno_conversion, &safe_terminal_coding); - { - int i; + for (int i = 0; i < coding_category_max; i++) + Fset (AREF (Vcoding_category_table, i), Qno_conversion); - for (i = 0; i < coding_category_max; i++) - Fset (AREF (Vcoding_category_table, i), Qno_conversion); - } #if defined (DOS_NT) system_eol_type = Qdos; #else |
