comparison src/coding.c @ 29275:b4ea9178e480

(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.
author Kenichi Handa <handa@m17n.org>
date Mon, 29 May 2000 11:25:30 +0000
parents c748b4b1c785
children b33b38d81020
comparison
equal deleted inserted replaced
29274:05e83ef9e129 29275:b4ea9178e480
1068 } while (0) 1068 } while (0)
1069 1069
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;
1077 { 1077 {
1078 struct composition_data *cmp_data 1078 struct composition_data *cmp_data
1116 #define CODING_ADD_COMPOSITION_COMPONENT(coding, component) \ 1116 #define CODING_ADD_COMPOSITION_COMPONENT(coding, component) \
1117 (coding->cmp_data->data[coding->cmp_data->used++] = component) 1117 (coding->cmp_data->data[coding->cmp_data->used++] = component)
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. */
1167 1168
1168 #define DECODE_COMPOSITION_END(c1) \ 1169 #define DECODE_COMPOSITION_END(c1) \
4466 4467
4467 /* Reflect the saved information about compositions to OBJ. 4468 /* Reflect the saved information about compositions 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;
4475 { 4476 {
4476 struct composition_data *cmp_data = coding->cmp_data; 4477 struct composition_data *cmp_data = coding->cmp_data;