aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa2003-03-07 02:18:35 +0000
committerKenichi Handa2003-03-07 02:18:35 +0000
commitb6871cc7ddc7901c8838df1708be1877d9c622f6 (patch)
tree824338ff2b165ecedf1548077b0d42c2d08fbca1 /src/coding.c
parentcb681b34551f44b27b7df2bdf3c6976cae23dbf9 (diff)
downloademacs-b6871cc7ddc7901c8838df1708be1877d9c622f6.tar.gz
emacs-b6871cc7ddc7901c8838df1708be1877d9c622f6.zip
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
composition components reaches the limit, terminate composing. (COMPOSITION_OK): New macro. (detect_coding_iso2022): Use it if an escapse sequence for composition is found. (coding_restore_composition): Adjust the number of composition components if it is not sane.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/coding.c b/src/coding.c
index 9dde90af15e..6b4a620a7dc 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -688,8 +688,16 @@ detect_coding_emacs_mule (src, src_end, multibytep)
688 688
689/* Record one COMPONENT (alternate character or composition rule). */ 689/* Record one COMPONENT (alternate character or composition rule). */
690 690
691#define CODING_ADD_COMPOSITION_COMPONENT(coding, component) \ 691#define CODING_ADD_COMPOSITION_COMPONENT(coding, component) \
692 (coding->cmp_data->data[coding->cmp_data->used++] = component) 692 do { \
693 coding->cmp_data->data[coding->cmp_data->used++] = component; \
694 if (coding->cmp_data->used - coding->cmp_data_start \
695 == COMPOSITION_DATA_MAX_BUNCH_LENGTH) \
696 { \
697 CODING_ADD_COMPOSITION_END (coding, coding->produced_char); \
698 coding->composing = COMPOSITION_NO; \
699 } \
700 } while (0)
693 701
694 702
695/* Get one byte from a data pointed by SRC and increment SRC. If SRC 703/* Get one byte from a data pointed by SRC and increment SRC. If SRC
@@ -1329,6 +1337,9 @@ enum iso_code_class_type iso_code_class[256];
1329#define SHIFT_OUT_OK(idx) \ 1337#define SHIFT_OUT_OK(idx) \
1330 (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding_system_table[idx], 1) >= 0) 1338 (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding_system_table[idx], 1) >= 0)
1331 1339
1340#define COMPOSITION_OK(idx) \
1341 (coding_system_table[idx]->composing != COMPOSITION_DISABLED)
1342
1332/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 1343/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
1333 Check if a text is encoded in ISO2022. If it is, return an 1344 Check if a text is encoded in ISO2022. If it is, return an
1334 integer in which appropriate flag bits any of: 1345 integer in which appropriate flag bits any of:
@@ -1406,7 +1417,30 @@ detect_coding_iso2022 (src, src_end, multibytep)
1406 else if (c >= '0' && c <= '4') 1417 else if (c >= '0' && c <= '4')
1407 { 1418 {
1408 /* ESC <Fp> for start/end composition. */ 1419 /* ESC <Fp> for start/end composition. */
1409 mask_found |= CODING_CATEGORY_MASK_ISO; 1420 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_7))
1421 mask_found |= CODING_CATEGORY_MASK_ISO_7;
1422 else
1423 mask &= ~CODING_CATEGORY_MASK_ISO_7;
1424 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_7_TIGHT))
1425 mask_found |= CODING_CATEGORY_MASK_ISO_7_TIGHT;
1426 else
1427 mask &= ~CODING_CATEGORY_MASK_ISO_7_TIGHT;
1428 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_8_1))
1429 mask_found |= CODING_CATEGORY_MASK_ISO_8_1;
1430 else
1431 mask &= ~CODING_CATEGORY_MASK_ISO_8_1;
1432 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_8_2))
1433 mask_found |= CODING_CATEGORY_MASK_ISO_8_2;
1434 else
1435 mask &= ~CODING_CATEGORY_MASK_ISO_8_2;
1436 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_7_ELSE))
1437 mask_found |= CODING_CATEGORY_MASK_ISO_7_ELSE;
1438 else
1439 mask &= ~CODING_CATEGORY_MASK_ISO_7_ELSE;
1440 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_8_ELSE))
1441 mask_found |= CODING_CATEGORY_MASK_ISO_8_ELSE;
1442 else
1443 mask &= ~CODING_CATEGORY_MASK_ISO_8_ELSE;
1410 break; 1444 break;
1411 } 1445 }
1412 else 1446 else
@@ -5289,6 +5323,9 @@ coding_restore_composition (coding, obj)
5289 int len = data[0] - 4, j; 5323 int len = data[0] - 4, j;
5290 Lisp_Object args[MAX_COMPOSITION_COMPONENTS * 2 - 1]; 5324 Lisp_Object args[MAX_COMPOSITION_COMPONENTS * 2 - 1];
5291 5325
5326 if (method == COMPOSITION_WITH_RULE_ALTCHARS
5327 && len % 2 == 0)
5328 len --;
5292 for (j = 0; j < len; j++) 5329 for (j = 0; j < len; j++)
5293 args[j] = make_number (data[4 + j]); 5330 args[j] = make_number (data[4 + j]);
5294 components = (method == COMPOSITION_WITH_ALTCHARS 5331 components = (method == COMPOSITION_WITH_ALTCHARS