diff options
| author | Kenichi Handa | 2000-05-29 11:25:30 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2000-05-29 11:25:30 +0000 |
| commit | 33fb63eb134510a7edc3c0abda2d7e146efc3458 (patch) | |
| tree | e56b567999c191ceb635fb3447455a7420a173fa /src/coding.c | |
| parent | 55fff3f969255ac056df423f9a4e6ce8cc592fc6 (diff) | |
| download | emacs-33fb63eb134510a7edc3c0abda2d7e146efc3458.tar.gz emacs-33fb63eb134510a7edc3c0abda2d7e146efc3458.zip | |
(DECODE_COMPOSITION_START): If coding->cmp_data is not
yet allocated, finish decoding with result
CODING_FINISH_INSUFFICIENT_CMP.
(coding_allocate_composition_data): Make it non-static.
(coding_restore_composition): Likewise.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/src/coding.c b/src/coding.c index 64d7e2afed1..cdcf312f60f 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -1070,7 +1070,7 @@ detect_coding_iso2022 (src, src_end) | |||
| 1070 | /* Allocate a memory block for storing information about compositions. | 1070 | /* Allocate a memory block for storing information about compositions. |
| 1071 | The block is chained to the already allocated blocks. */ | 1071 | The block is chained to the already allocated blocks. */ |
| 1072 | 1072 | ||
| 1073 | static void | 1073 | void |
| 1074 | coding_allocate_composition_data (coding, char_offset) | 1074 | coding_allocate_composition_data (coding, char_offset) |
| 1075 | struct coding_system *coding; | 1075 | struct coding_system *coding; |
| 1076 | int char_offset; | 1076 | int char_offset; |
| @@ -1118,49 +1118,50 @@ coding_allocate_composition_data (coding, char_offset) | |||
| 1118 | 1118 | ||
| 1119 | /* Handle compositoin start sequence ESC 0, ESC 2, ESC 3, or ESC 4. */ | 1119 | /* Handle compositoin start sequence ESC 0, ESC 2, ESC 3, or ESC 4. */ |
| 1120 | 1120 | ||
| 1121 | #define DECODE_COMPOSITION_START(c1) \ | 1121 | #define DECODE_COMPOSITION_START(c1) \ |
| 1122 | do { \ | 1122 | do { \ |
| 1123 | if (coding->composing == COMPOSITION_DISABLED) \ | 1123 | if (coding->composing == COMPOSITION_DISABLED) \ |
| 1124 | { \ | 1124 | { \ |
| 1125 | *dst++ = ISO_CODE_ESC; \ | 1125 | *dst++ = ISO_CODE_ESC; \ |
| 1126 | *dst++ = c1 & 0x7f; \ | 1126 | *dst++ = c1 & 0x7f; \ |
| 1127 | coding->produced_char += 2; \ | 1127 | coding->produced_char += 2; \ |
| 1128 | } \ | 1128 | } \ |
| 1129 | else if (!COMPOSING_P (coding)) \ | 1129 | else if (!COMPOSING_P (coding)) \ |
| 1130 | { \ | 1130 | { \ |
| 1131 | /* This is surely the start of a composition. We must be sure \ | 1131 | /* This is surely the start of a composition. We must be sure \ |
| 1132 | that coding->cmp_data has enough space to store the \ | 1132 | that coding->cmp_data has enough space to store the \ |
| 1133 | information about the composition. If not, terminate the \ | 1133 | information about the composition. If not, terminate the \ |
| 1134 | current decoding loop, allocate one more memory block for \ | 1134 | current decoding loop, allocate one more memory block for \ |
| 1135 | coding->cmp_data in the calller, then start the decoding \ | 1135 | coding->cmp_data in the calller, then start the decoding \ |
| 1136 | loop again. We can't allocate memory here directly because \ | 1136 | loop again. We can't allocate memory here directly because \ |
| 1137 | it may cause buffer/string relocation. */ \ | 1137 | it may cause buffer/string relocation. */ \ |
| 1138 | if (coding->cmp_data->used + COMPOSITION_DATA_MAX_BUNCH_LENGTH \ | 1138 | if (!coding->cmp_data \ |
| 1139 | >= COMPOSITION_DATA_SIZE) \ | 1139 | || (coding->cmp_data->used + COMPOSITION_DATA_MAX_BUNCH_LENGTH \ |
| 1140 | { \ | 1140 | >= COMPOSITION_DATA_SIZE)) \ |
| 1141 | coding->result = CODING_FINISH_INSUFFICIENT_CMP; \ | 1141 | { \ |
| 1142 | goto label_end_of_loop; \ | 1142 | coding->result = CODING_FINISH_INSUFFICIENT_CMP; \ |
| 1143 | } \ | 1143 | goto label_end_of_loop; \ |
| 1144 | coding->composing = (c1 == '0' ? COMPOSITION_RELATIVE \ | 1144 | } \ |
| 1145 | : c1 == '2' ? COMPOSITION_WITH_RULE \ | 1145 | coding->composing = (c1 == '0' ? COMPOSITION_RELATIVE \ |
| 1146 | : c1 == '3' ? COMPOSITION_WITH_ALTCHARS \ | 1146 | : c1 == '2' ? COMPOSITION_WITH_RULE \ |
| 1147 | : COMPOSITION_WITH_RULE_ALTCHARS); \ | 1147 | : c1 == '3' ? COMPOSITION_WITH_ALTCHARS \ |
| 1148 | CODING_ADD_COMPOSITION_START (coding, coding->produced_char, \ | 1148 | : COMPOSITION_WITH_RULE_ALTCHARS); \ |
| 1149 | coding->composing); \ | 1149 | CODING_ADD_COMPOSITION_START (coding, coding->produced_char, \ |
| 1150 | coding->composition_rule_follows = 0; \ | 1150 | coding->composing); \ |
| 1151 | } \ | 1151 | coding->composition_rule_follows = 0; \ |
| 1152 | else \ | 1152 | } \ |
| 1153 | { \ | 1153 | else \ |
| 1154 | /* We are already handling a composition. If the method is \ | 1154 | { \ |
| 1155 | the following two, the codes following the current escape \ | 1155 | /* We are already handling a composition. If the method is \ |
| 1156 | sequence are actual characters stored in a buffer. */ \ | 1156 | the following two, the codes following the current escape \ |
| 1157 | if (coding->composing == COMPOSITION_WITH_ALTCHARS \ | 1157 | sequence are actual characters stored in a buffer. */ \ |
| 1158 | || coding->composing == COMPOSITION_WITH_RULE_ALTCHARS) \ | 1158 | if (coding->composing == COMPOSITION_WITH_ALTCHARS \ |
| 1159 | { \ | 1159 | || coding->composing == COMPOSITION_WITH_RULE_ALTCHARS) \ |
| 1160 | coding->composing = COMPOSITION_RELATIVE; \ | 1160 | { \ |
| 1161 | coding->composition_rule_follows = 0; \ | 1161 | coding->composing = COMPOSITION_RELATIVE; \ |
| 1162 | } \ | 1162 | coding->composition_rule_follows = 0; \ |
| 1163 | } \ | 1163 | } \ |
| 1164 | } \ | ||
| 1164 | } while (0) | 1165 | } while (0) |
| 1165 | 1166 | ||
| 1166 | /* Handle compositoin end sequence ESC 1. */ | 1167 | /* Handle compositoin end sequence ESC 1. */ |
| @@ -4468,7 +4469,7 @@ coding_save_composition (coding, from, to, obj) | |||
| 4468 | CODING->cmp_data points to a memory block for the informaiton. OBJ | 4469 | CODING->cmp_data points to a memory block for the informaiton. OBJ |
| 4469 | is a buffer or a string, defaults to the current buffer. */ | 4470 | is a buffer or a string, defaults to the current buffer. */ |
| 4470 | 4471 | ||
| 4471 | static void | 4472 | void |
| 4472 | coding_restore_composition (coding, obj) | 4473 | coding_restore_composition (coding, obj) |
| 4473 | struct coding_system *coding; | 4474 | struct coding_system *coding; |
| 4474 | Lisp_Object obj; | 4475 | Lisp_Object obj; |