comparison src/w32term.c @ 50163:6f30f0db5f30

(w32_encode_char): Prevent double-byte chars from crashing Emacs.
author Jason Rumney <jasonr@gnu.org>
date Sun, 16 Mar 2003 22:11:04 +0000
parents 10038ae9db85
children c8ea5e4b2129
comparison
equal deleted inserted replaced
50162:1404922b76b3 50163:6f30f0db5f30
1132 int * two_byte_p; 1132 int * two_byte_p;
1133 { 1133 {
1134 int charset = CHAR_CHARSET (c); 1134 int charset = CHAR_CHARSET (c);
1135 int codepage; 1135 int codepage;
1136 int unicode_p = 0; 1136 int unicode_p = 0;
1137 int internal_two_byte_p = 0;
1137 1138
1138 XFontStruct *font = font_info->font; 1139 XFontStruct *font = font_info->font;
1139 1140
1140 xassert (two_byte_p); 1141 internal_two_byte_p = w32_font_is_double_byte (font);
1141
1142 if (two_byte_p)
1143 *two_byte_p = w32_font_is_double_byte (font);
1144 1142
1145 /* FONT_INFO may define a scheme by which to encode byte1 and byte2. 1143 /* FONT_INFO may define a scheme by which to encode byte1 and byte2.
1146 This may be either a program in a special encoder language or a 1144 This may be either a program in a special encoder language or a
1147 fixed encoding. */ 1145 fixed encoding. */
1148 if (font_info->font_encoder) 1146 if (font_info->font_encoder)
1165 1163
1166 ccl_driver (ccl, NULL, NULL, 0, 0, NULL); 1164 ccl_driver (ccl, NULL, NULL, 0, 0, NULL);
1167 1165
1168 /* We assume that MSBs are appropriately set/reset by CCL 1166 /* We assume that MSBs are appropriately set/reset by CCL
1169 program. */ 1167 program. */
1170 if (!*two_byte_p) /* 1-byte font */ 1168 if (!internal_two_byte_p) /* 1-byte font */
1171 STORE_XCHAR2B (char2b, 0, ccl->reg[1]); 1169 STORE_XCHAR2B (char2b, 0, ccl->reg[1]);
1172 else 1170 else
1173 STORE_XCHAR2B (char2b, ccl->reg[1], ccl->reg[2]); 1171 STORE_XCHAR2B (char2b, ccl->reg[1], ccl->reg[2]);
1174 } 1172 }
1175 else if (font_info->encoding[charset]) 1173 else if (font_info->encoding[charset])
1212 MultiByteToWideChar (codepage, 0, temp, 2, char2b, 1); 1210 MultiByteToWideChar (codepage, 0, temp, 2, char2b, 1);
1213 else 1211 else
1214 MultiByteToWideChar (codepage, 0, temp+1, 1, char2b, 1); 1212 MultiByteToWideChar (codepage, 0, temp+1, 1, char2b, 1);
1215 } 1213 }
1216 unicode_p = 1; 1214 unicode_p = 1;
1217 *two_byte_p = 1; 1215 internal_two_byte_p = 1;
1218 } 1216 }
1217
1218 if (two_byte_p)
1219 *two_byte_p = internal_two_byte_p;
1220
1219 if (!font) 1221 if (!font)
1220 return UNKNOWN_FONT; 1222 return UNKNOWN_FONT;
1221 else if (font->bdf && CHARSET_DIMENSION (charset) == 1) 1223 else if (font->bdf && CHARSET_DIMENSION (charset) == 1)
1222 return BDF_1D_FONT; 1224 return BDF_1D_FONT;
1223 else if (font->bdf) 1225 else if (font->bdf)