diff options
| author | Tom Tromey | 2013-03-08 11:57:29 -0700 |
|---|---|---|
| committer | Tom Tromey | 2013-03-08 11:57:29 -0700 |
| commit | 71f91792e3013b397996905224f387da5cc539a9 (patch) | |
| tree | 4c3d3ba909e76deea1cdf73b73fca67a57149465 /src/coding.c | |
| parent | 6f4de085f065e11f4df3195d47479f28f5ef08ba (diff) | |
| parent | b5426561089d39f18b42bed9dbfcb531f43ed562 (diff) | |
| download | emacs-71f91792e3013b397996905224f387da5cc539a9.tar.gz emacs-71f91792e3013b397996905224f387da5cc539a9.zip | |
merge from trunk
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 86 |
1 files changed, 34 insertions, 52 deletions
diff --git a/src/coding.c b/src/coding.c index a9bf9032a69..32da72ab626 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -322,8 +322,7 @@ Lisp_Object Qcall_process, Qcall_process_region; | |||
| 322 | Lisp_Object Qstart_process, Qopen_network_stream; | 322 | Lisp_Object Qstart_process, Qopen_network_stream; |
| 323 | static Lisp_Object Qtarget_idx; | 323 | static Lisp_Object Qtarget_idx; |
| 324 | 324 | ||
| 325 | static Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source; | 325 | static Lisp_Object Qinsufficient_source, Qinvalid_source, Qinterrupted; |
| 326 | static Lisp_Object Qinterrupted, Qinsufficient_memory; | ||
| 327 | 326 | ||
| 328 | /* If a symbol has this property, evaluate the value to define the | 327 | /* If a symbol has this property, evaluate the value to define the |
| 329 | symbol as a coding system. */ | 328 | symbol as a coding system. */ |
| @@ -820,18 +819,12 @@ record_conversion_result (struct coding_system *coding, | |||
| 820 | case CODING_RESULT_INSUFFICIENT_SRC: | 819 | case CODING_RESULT_INSUFFICIENT_SRC: |
| 821 | Vlast_code_conversion_error = Qinsufficient_source; | 820 | Vlast_code_conversion_error = Qinsufficient_source; |
| 822 | break; | 821 | break; |
| 823 | case CODING_RESULT_INCONSISTENT_EOL: | ||
| 824 | Vlast_code_conversion_error = Qinconsistent_eol; | ||
| 825 | break; | ||
| 826 | case CODING_RESULT_INVALID_SRC: | 822 | case CODING_RESULT_INVALID_SRC: |
| 827 | Vlast_code_conversion_error = Qinvalid_source; | 823 | Vlast_code_conversion_error = Qinvalid_source; |
| 828 | break; | 824 | break; |
| 829 | case CODING_RESULT_INTERRUPT: | 825 | case CODING_RESULT_INTERRUPT: |
| 830 | Vlast_code_conversion_error = Qinterrupted; | 826 | Vlast_code_conversion_error = Qinterrupted; |
| 831 | break; | 827 | break; |
| 832 | case CODING_RESULT_INSUFFICIENT_MEM: | ||
| 833 | Vlast_code_conversion_error = Qinsufficient_memory; | ||
| 834 | break; | ||
| 835 | case CODING_RESULT_INSUFFICIENT_DST: | 828 | case CODING_RESULT_INSUFFICIENT_DST: |
| 836 | /* Don't record this error in Vlast_code_conversion_error | 829 | /* Don't record this error in Vlast_code_conversion_error |
| 837 | because it happens just temporarily and is resolved when the | 830 | because it happens just temporarily and is resolved when the |
| @@ -3057,20 +3050,7 @@ detect_coding_iso_2022 (struct coding_system *coding, | |||
| 3057 | } | 3050 | } |
| 3058 | if (single_shifting) | 3051 | if (single_shifting) |
| 3059 | break; | 3052 | break; |
| 3060 | check_extra_latin: | 3053 | goto check_extra_latin; |
| 3061 | if (! VECTORP (Vlatin_extra_code_table) | ||
| 3062 | || NILP (AREF (Vlatin_extra_code_table, c))) | ||
| 3063 | { | ||
| 3064 | rejected = CATEGORY_MASK_ISO; | ||
| 3065 | break; | ||
| 3066 | } | ||
| 3067 | if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) | ||
| 3068 | & CODING_ISO_FLAG_LATIN_EXTRA) | ||
| 3069 | found |= CATEGORY_MASK_ISO_8_1; | ||
| 3070 | else | ||
| 3071 | rejected |= CATEGORY_MASK_ISO_8_1; | ||
| 3072 | rejected |= CATEGORY_MASK_ISO_8_2; | ||
| 3073 | break; | ||
| 3074 | 3054 | ||
| 3075 | default: | 3055 | default: |
| 3076 | if (c < 0) | 3056 | if (c < 0) |
| @@ -3121,6 +3101,20 @@ detect_coding_iso_2022 (struct coding_system *coding, | |||
| 3121 | } | 3101 | } |
| 3122 | break; | 3102 | break; |
| 3123 | } | 3103 | } |
| 3104 | check_extra_latin: | ||
| 3105 | if (! VECTORP (Vlatin_extra_code_table) | ||
| 3106 | || NILP (AREF (Vlatin_extra_code_table, c))) | ||
| 3107 | { | ||
| 3108 | rejected = CATEGORY_MASK_ISO; | ||
| 3109 | break; | ||
| 3110 | } | ||
| 3111 | if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) | ||
| 3112 | & CODING_ISO_FLAG_LATIN_EXTRA) | ||
| 3113 | found |= CATEGORY_MASK_ISO_8_1; | ||
| 3114 | else | ||
| 3115 | rejected |= CATEGORY_MASK_ISO_8_1; | ||
| 3116 | rejected |= CATEGORY_MASK_ISO_8_2; | ||
| 3117 | break; | ||
| 3124 | } | 3118 | } |
| 3125 | } | 3119 | } |
| 3126 | detect_info->rejected |= CATEGORY_MASK_ISO; | 3120 | detect_info->rejected |= CATEGORY_MASK_ISO; |
| @@ -6883,22 +6877,8 @@ produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos) | |||
| 6883 | 6877 | ||
| 6884 | #define ALLOC_CONVERSION_WORK_AREA(coding) \ | 6878 | #define ALLOC_CONVERSION_WORK_AREA(coding) \ |
| 6885 | do { \ | 6879 | do { \ |
| 6886 | int size = CHARBUF_SIZE; \ | 6880 | coding->charbuf = SAFE_ALLOCA (CHARBUF_SIZE * sizeof (int)); \ |
| 6887 | \ | 6881 | coding->charbuf_size = CHARBUF_SIZE; \ |
| 6888 | coding->charbuf = NULL; \ | ||
| 6889 | while (size > 1024) \ | ||
| 6890 | { \ | ||
| 6891 | coding->charbuf = alloca (sizeof (int) * size); \ | ||
| 6892 | if (coding->charbuf) \ | ||
| 6893 | break; \ | ||
| 6894 | size >>= 1; \ | ||
| 6895 | } \ | ||
| 6896 | if (! coding->charbuf) \ | ||
| 6897 | { \ | ||
| 6898 | record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \ | ||
| 6899 | return; \ | ||
| 6900 | } \ | ||
| 6901 | coding->charbuf_size = size; \ | ||
| 6902 | } while (0) | 6882 | } while (0) |
| 6903 | 6883 | ||
| 6904 | 6884 | ||
| @@ -6967,6 +6947,8 @@ decode_coding (struct coding_system *coding) | |||
| 6967 | int carryover; | 6947 | int carryover; |
| 6968 | int i; | 6948 | int i; |
| 6969 | 6949 | ||
| 6950 | USE_SAFE_ALLOCA; | ||
| 6951 | |||
| 6970 | if (BUFFERP (coding->src_object) | 6952 | if (BUFFERP (coding->src_object) |
| 6971 | && coding->src_pos > 0 | 6953 | && coding->src_pos > 0 |
| 6972 | && coding->src_pos < GPT | 6954 | && coding->src_pos < GPT |
| @@ -7089,6 +7071,8 @@ decode_coding (struct coding_system *coding) | |||
| 7089 | bset_undo_list (current_buffer, undo_list); | 7071 | bset_undo_list (current_buffer, undo_list); |
| 7090 | record_insert (coding->dst_pos, coding->produced_char); | 7072 | record_insert (coding->dst_pos, coding->produced_char); |
| 7091 | } | 7073 | } |
| 7074 | |||
| 7075 | SAFE_FREE (); | ||
| 7092 | } | 7076 | } |
| 7093 | 7077 | ||
| 7094 | 7078 | ||
| @@ -7372,6 +7356,8 @@ encode_coding (struct coding_system *coding) | |||
| 7372 | int max_lookup; | 7356 | int max_lookup; |
| 7373 | struct ccl_spec cclspec; | 7357 | struct ccl_spec cclspec; |
| 7374 | 7358 | ||
| 7359 | USE_SAFE_ALLOCA; | ||
| 7360 | |||
| 7375 | attrs = CODING_ID_ATTRS (coding->id); | 7361 | attrs = CODING_ID_ATTRS (coding->id); |
| 7376 | if (coding->encoder == encode_coding_raw_text) | 7362 | if (coding->encoder == encode_coding_raw_text) |
| 7377 | translation_table = Qnil, max_lookup = 0; | 7363 | translation_table = Qnil, max_lookup = 0; |
| @@ -7406,6 +7392,8 @@ encode_coding (struct coding_system *coding) | |||
| 7406 | 7392 | ||
| 7407 | if (BUFFERP (coding->dst_object) && coding->produced_char > 0) | 7393 | if (BUFFERP (coding->dst_object) && coding->produced_char > 0) |
| 7408 | insert_from_gap (coding->produced_char, coding->produced); | 7394 | insert_from_gap (coding->produced_char, coding->produced); |
| 7395 | |||
| 7396 | SAFE_FREE (); | ||
| 7409 | } | 7397 | } |
| 7410 | 7398 | ||
| 7411 | 7399 | ||
| @@ -7694,14 +7682,8 @@ decode_coding_object (struct coding_system *coding, | |||
| 7694 | set_buffer_internal (XBUFFER (coding->dst_object)); | 7682 | set_buffer_internal (XBUFFER (coding->dst_object)); |
| 7695 | if (dst_bytes < coding->produced) | 7683 | if (dst_bytes < coding->produced) |
| 7696 | { | 7684 | { |
| 7685 | eassert (coding->produced > 0); | ||
| 7697 | destination = xrealloc (destination, coding->produced); | 7686 | destination = xrealloc (destination, coding->produced); |
| 7698 | if (! destination) | ||
| 7699 | { | ||
| 7700 | record_conversion_result (coding, | ||
| 7701 | CODING_RESULT_INSUFFICIENT_MEM); | ||
| 7702 | unbind_to (count, Qnil); | ||
| 7703 | return; | ||
| 7704 | } | ||
| 7705 | if (BEGV < GPT && GPT < BEGV + coding->produced_char) | 7687 | if (BEGV < GPT && GPT < BEGV + coding->produced_char) |
| 7706 | move_gap_both (BEGV, BEGV_BYTE); | 7688 | move_gap_both (BEGV, BEGV_BYTE); |
| 7707 | memcpy (destination, BEGV_ADDR, coding->produced); | 7689 | memcpy (destination, BEGV_ADDR, coding->produced); |
| @@ -9482,7 +9464,7 @@ make_subsidiaries (Lisp_Object base) | |||
| 9482 | int i; | 9464 | int i; |
| 9483 | 9465 | ||
| 9484 | memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); | 9466 | memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); |
| 9485 | subsidiaries = Fmake_vector (make_number (3), Qnil); | 9467 | subsidiaries = make_uninit_vector (3); |
| 9486 | for (i = 0; i < 3; i++) | 9468 | for (i = 0; i < 3; i++) |
| 9487 | { | 9469 | { |
| 9488 | strcpy (buf + base_name_len, suffixes[i]); | 9470 | strcpy (buf + base_name_len, suffixes[i]); |
| @@ -9782,7 +9764,7 @@ usage: (define-coding-system-internal ...) */) | |||
| 9782 | CHECK_VECTOR (initial); | 9764 | CHECK_VECTOR (initial); |
| 9783 | for (i = 0; i < 4; i++) | 9765 | for (i = 0; i < 4; i++) |
| 9784 | { | 9766 | { |
| 9785 | val = Faref (initial, make_number (i)); | 9767 | val = AREF (initial, i); |
| 9786 | if (! NILP (val)) | 9768 | if (! NILP (val)) |
| 9787 | { | 9769 | { |
| 9788 | struct charset *charset; | 9770 | struct charset *charset; |
| @@ -9987,7 +9969,8 @@ usage: (define-coding-system-internal ...) */) | |||
| 9987 | this_name = AREF (eol_type, i); | 9969 | this_name = AREF (eol_type, i); |
| 9988 | this_aliases = Fcons (this_name, Qnil); | 9970 | this_aliases = Fcons (this_name, Qnil); |
| 9989 | this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac); | 9971 | this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac); |
| 9990 | this_spec = Fmake_vector (make_number (3), attrs); | 9972 | this_spec = make_uninit_vector (3); |
| 9973 | ASET (this_spec, 0, attrs); | ||
| 9991 | ASET (this_spec, 1, this_aliases); | 9974 | ASET (this_spec, 1, this_aliases); |
| 9992 | ASET (this_spec, 2, this_eol_type); | 9975 | ASET (this_spec, 2, this_eol_type); |
| 9993 | Fputhash (this_name, this_spec, Vcoding_system_hash_table); | 9976 | Fputhash (this_name, this_spec, Vcoding_system_hash_table); |
| @@ -10000,7 +9983,8 @@ usage: (define-coding-system-internal ...) */) | |||
| 10000 | } | 9983 | } |
| 10001 | } | 9984 | } |
| 10002 | 9985 | ||
| 10003 | spec_vec = Fmake_vector (make_number (3), attrs); | 9986 | spec_vec = make_uninit_vector (3); |
| 9987 | ASET (spec_vec, 0, attrs); | ||
| 10004 | ASET (spec_vec, 1, aliases); | 9988 | ASET (spec_vec, 1, aliases); |
| 10005 | ASET (spec_vec, 2, eol_type); | 9989 | ASET (spec_vec, 2, eol_type); |
| 10006 | 9990 | ||
| @@ -10405,10 +10389,8 @@ syms_of_coding (void) | |||
| 10405 | intern_c_string ("coding-category-undecided")); | 10389 | intern_c_string ("coding-category-undecided")); |
| 10406 | 10390 | ||
| 10407 | DEFSYM (Qinsufficient_source, "insufficient-source"); | 10391 | DEFSYM (Qinsufficient_source, "insufficient-source"); |
| 10408 | DEFSYM (Qinconsistent_eol, "inconsistent-eol"); | ||
| 10409 | DEFSYM (Qinvalid_source, "invalid-source"); | 10392 | DEFSYM (Qinvalid_source, "invalid-source"); |
| 10410 | DEFSYM (Qinterrupted, "interrupted"); | 10393 | DEFSYM (Qinterrupted, "interrupted"); |
| 10411 | DEFSYM (Qinsufficient_memory, "insufficient-memory"); | ||
| 10412 | DEFSYM (Qcoding_system_define_form, "coding-system-define-form"); | 10394 | DEFSYM (Qcoding_system_define_form, "coding-system-define-form"); |
| 10413 | 10395 | ||
| 10414 | defsubr (&Scoding_system_p); | 10396 | defsubr (&Scoding_system_p); |
| @@ -10709,7 +10691,7 @@ reading if you suppress escape sequence detection. | |||
| 10709 | 10691 | ||
| 10710 | The other way to read escape sequences in a file without decoding is | 10692 | The other way to read escape sequences in a file without decoding is |
| 10711 | to explicitly specify some coding system that doesn't use ISO-2022 | 10693 | to explicitly specify some coding system that doesn't use ISO-2022 |
| 10712 | escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument]. */); | 10694 | escape sequence (e.g., `latin-1') on reading by \\[universal-coding-system-argument]. */); |
| 10713 | inhibit_iso_escape_detection = 0; | 10695 | inhibit_iso_escape_detection = 0; |
| 10714 | 10696 | ||
| 10715 | DEFVAR_BOOL ("inhibit-null-byte-detection", | 10697 | DEFVAR_BOOL ("inhibit-null-byte-detection", |