Mercurial > emacs
comparison src/coding.c @ 70520:b6740a317343
(setup_coding_system): For invalid coding-system, set
coding->eol_type to CODING_EOL_UNDECIDED.
(encode_coding): Cancel previous change.
(shrink_encoding_region): Likewise.
(code_convert_region1): Likewise.
(code_convert_string1): Likewise.
(code_convert_string_norecord): Likewise.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Mon, 08 May 2006 05:25:02 +0000 |
| parents | d4a5619e5025 |
| children | 576f5c8ea6e4 1321f6cfb389 |
comparison
equal
deleted
inserted
replaced
| 70519:3731408d78da | 70520:b6740a317343 |
|---|---|
| 382 /* Mnemonic string to indicate format of end-of-line is not yet | 382 /* Mnemonic string to indicate format of end-of-line is not yet |
| 383 decided. */ | 383 decided. */ |
| 384 Lisp_Object eol_mnemonic_undecided; | 384 Lisp_Object eol_mnemonic_undecided; |
| 385 | 385 |
| 386 /* Format of end-of-line decided by system. This is CODING_EOL_LF on | 386 /* Format of end-of-line decided by system. This is CODING_EOL_LF on |
| 387 Unix, CODING_EOL_CRLF on DOS/Windows, and CODING_EOL_CR on Mac. */ | 387 Unix, CODING_EOL_CRLF on DOS/Windows, and CODING_EOL_CR on Mac. |
| 388 This has an effect only for external encoding (i.e. for output to | |
| 389 file and process), not for in-buffer or Lisp string encoding. */ | |
| 388 int system_eol_type; | 390 int system_eol_type; |
| 389 | 391 |
| 390 #ifdef emacs | 392 #ifdef emacs |
| 391 | 393 |
| 392 /* Information about which coding system is safe for which chars. | 394 /* Information about which coding system is safe for which chars. |
| 3922 | 3924 |
| 3923 label_invalid_coding_system: | 3925 label_invalid_coding_system: |
| 3924 coding->type = coding_type_no_conversion; | 3926 coding->type = coding_type_no_conversion; |
| 3925 coding->category_idx = CODING_CATEGORY_IDX_BINARY; | 3927 coding->category_idx = CODING_CATEGORY_IDX_BINARY; |
| 3926 coding->common_flags = 0; | 3928 coding->common_flags = 0; |
| 3927 coding->eol_type = NILP (coding_system) ? system_eol_type : CODING_EOL_LF; | 3929 coding->eol_type = CODING_EOL_UNDECIDED; |
| 3928 if (coding->eol_type != CODING_EOL_LF) | |
| 3929 coding->common_flags | |
| 3930 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; | |
| 3931 coding->pre_write_conversion = coding->post_read_conversion = Qnil; | 3930 coding->pre_write_conversion = coding->post_read_conversion = Qnil; |
| 3932 return NILP (coding_system) ? 0 : -1; | 3931 return NILP (coding_system) ? 0 : -1; |
| 3933 } | 3932 } |
| 3934 | 3933 |
| 3935 /* Free memory blocks allocated for storing composition information. */ | 3934 /* Free memory blocks allocated for storing composition information. */ |
| 5002 coding->produced = coding->produced_char = 0; | 5001 coding->produced = coding->produced_char = 0; |
| 5003 coding->consumed = coding->consumed_char = 0; | 5002 coding->consumed = coding->consumed_char = 0; |
| 5004 coding->errors = 0; | 5003 coding->errors = 0; |
| 5005 coding->result = CODING_FINISH_NORMAL; | 5004 coding->result = CODING_FINISH_NORMAL; |
| 5006 if (coding->eol_type == CODING_EOL_UNDECIDED) | 5005 if (coding->eol_type == CODING_EOL_UNDECIDED) |
| 5007 coding->eol_type = system_eol_type; | 5006 coding->eol_type = CODING_EOL_LF; |
| 5008 | 5007 |
| 5009 switch (coding->type) | 5008 switch (coding->type) |
| 5010 { | 5009 { |
| 5011 case coding_type_sjis: | 5010 case coding_type_sjis: |
| 5012 encode_coding_sjis_big5 (coding, source, destination, | 5011 encode_coding_sjis_big5 (coding, source, destination, |
| 5259 Lisp_Object translation_table; | 5258 Lisp_Object translation_table; |
| 5260 | 5259 |
| 5261 if (coding->type == coding_type_ccl | 5260 if (coding->type == coding_type_ccl |
| 5262 || coding->eol_type == CODING_EOL_CRLF | 5261 || coding->eol_type == CODING_EOL_CRLF |
| 5263 || coding->eol_type == CODING_EOL_CR | 5262 || coding->eol_type == CODING_EOL_CR |
| 5264 || (coding->eol_type == CODING_EOL_UNDECIDED | |
| 5265 && system_eol_type != CODING_EOL_LF) | |
| 5266 || (coding->cmp_data && coding->cmp_data->used > 0)) | 5263 || (coding->cmp_data && coding->cmp_data->used > 0)) |
| 5267 { | 5264 { |
| 5268 /* We can't skip any data. */ | 5265 /* We can't skip any data. */ |
| 5269 return; | 5266 return; |
| 5270 } | 5267 } |
| 7116 | 7113 |
| 7117 validate_region (&start, &end); | 7114 validate_region (&start, &end); |
| 7118 from = XFASTINT (start); | 7115 from = XFASTINT (start); |
| 7119 to = XFASTINT (end); | 7116 to = XFASTINT (end); |
| 7120 | 7117 |
| 7121 if (NILP (coding_system) && system_eol_type == CODING_EOL_LF) | 7118 if (NILP (coding_system)) |
| 7122 return make_number (to - from); | 7119 return make_number (to - from); |
| 7123 | 7120 |
| 7124 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | 7121 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
| 7125 error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); | 7122 error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
| 7126 | 7123 |
| 7171 struct coding_system coding; | 7168 struct coding_system coding; |
| 7172 | 7169 |
| 7173 CHECK_STRING (string); | 7170 CHECK_STRING (string); |
| 7174 CHECK_SYMBOL (coding_system); | 7171 CHECK_SYMBOL (coding_system); |
| 7175 | 7172 |
| 7176 if (NILP (coding_system) && system_eol_type == CODING_EOL_LF) | 7173 if (NILP (coding_system)) |
| 7177 return (NILP (nocopy) ? Fcopy_sequence (string) : string); | 7174 return (NILP (nocopy) ? Fcopy_sequence (string) : string); |
| 7178 | 7175 |
| 7179 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | 7176 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
| 7180 error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); | 7177 error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
| 7181 | 7178 |
| 7230 struct coding_system coding; | 7227 struct coding_system coding; |
| 7231 | 7228 |
| 7232 CHECK_STRING (string); | 7229 CHECK_STRING (string); |
| 7233 CHECK_SYMBOL (coding_system); | 7230 CHECK_SYMBOL (coding_system); |
| 7234 | 7231 |
| 7235 if (NILP (coding_system) && system_eol_type == CODING_EOL_LF) | 7232 if (NILP (coding_system)) |
| 7236 return string; | 7233 return string; |
| 7237 | 7234 |
| 7238 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | 7235 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
| 7239 error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); | 7236 error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
| 7240 | 7237 |
