Mercurial > hg > xemacs-beta
comparison src/mule-ccl.c @ 462:0784d089fdc9 r21-2-46
Import from CVS: tag r21-2-46
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:44:37 +0200 |
parents | 223736d75acb |
children | 183866b06e0b |
comparison
equal
deleted
inserted
replaced
461:120ed4009e51 | 462:0784d089fdc9 |
---|---|
675 r[7] = LOWER_BYTE (DE-SJIS (Y, Z)) */ | 675 r[7] = LOWER_BYTE (DE-SJIS (Y, Z)) */ |
676 #define CCL_ENCODE_SJIS 0x17 /* X = HIGHER_BYTE (SJIS (Y, Z)) | 676 #define CCL_ENCODE_SJIS 0x17 /* X = HIGHER_BYTE (SJIS (Y, Z)) |
677 r[7] = LOWER_BYTE (SJIS (Y, Z) */ | 677 r[7] = LOWER_BYTE (SJIS (Y, Z) */ |
678 | 678 |
679 /* Terminate CCL program successfully. */ | 679 /* Terminate CCL program successfully. */ |
680 #define CCL_SUCCESS \ | 680 #define CCL_SUCCESS \ |
681 do { \ | 681 do { \ |
682 ccl->status = CCL_STAT_SUCCESS; \ | 682 ccl->status = CCL_STAT_SUCCESS; \ |
683 /* The "if (1)" inhibits the warning \ | 683 /* The "if (1)" inhibits the warning \ |
684 "end-of loop code not reached" */ \ | 684 "end-of loop code not reached" */ \ |
685 if (1) goto ccl_finish; \ | 685 if (1) goto ccl_finish; \ |
686 } while (0) | 686 } while (0) |
687 | 687 |
688 /* Suspend CCL program because of reading from empty input buffer or | 688 /* Suspend CCL program because of reading from empty input buffer or |
689 writing to full output buffer. When this program is resumed, the | 689 writing to full output buffer. When this program is resumed, the |
690 same I/O command is executed. */ | 690 same I/O command is executed. */ |
691 #define CCL_SUSPEND(stat) \ | 691 #define CCL_SUSPEND(stat) \ |
692 do { \ | 692 do { \ |
693 ic--; \ | 693 ic--; \ |
694 ccl->status = (stat); \ | 694 ccl->status = (stat); \ |
695 /* The "if (1)" inhibits the warning \ | 695 /* The "if (1)" inhibits the warning \ |
696 "end-of loop code not reached" */ \ | 696 "end-of loop code not reached" */ \ |
697 if (1) goto ccl_finish; \ | 697 if (1) goto ccl_finish; \ |
698 } while (0) | 698 } while (0) |
699 | 699 |
700 /* Terminate CCL program because of invalid command. Should not occur | 700 /* Terminate CCL program because of invalid command. Should not occur |
701 in the normal case. */ | 701 in the normal case. */ |
702 #define CCL_INVALID_CMD \ | 702 #define CCL_INVALID_CMD \ |
703 do { \ | 703 do { \ |
704 ccl->status = CCL_STAT_INVALID_CMD; \ | 704 ccl->status = CCL_STAT_INVALID_CMD; \ |
705 /* The "if (1)" inhibits the warning \ | 705 /* The "if (1)" inhibits the warning \ |
706 "end-of loop code not reached" */ \ | 706 "end-of loop code not reached" */ \ |
707 if (1) goto ccl_error_handler; \ | 707 if (1) goto ccl_error_handler; \ |
708 } while (0) | 708 } while (0) |
709 | 709 |
710 /* Encode one character CH to multibyte form and write to the current | 710 /* Encode one character CH to multibyte form and write to the current |
711 output buffer. At encoding time, if CH is less than 256, CH is | 711 output buffer. At encoding time, if CH is less than 256, CH is |
712 written as is. At decoding time, if CH cannot be regarded as an | 712 written as is. At decoding time, if CH cannot be regarded as an |
713 ASCII character, write it in multibyte form. */ | 713 ASCII character, write it in multibyte form. */ |
1281 { | 1281 { |
1282 case CCL_ReadMultibyteChar2: | 1282 case CCL_ReadMultibyteChar2: |
1283 if (!src) | 1283 if (!src) |
1284 CCL_INVALID_CMD; | 1284 CCL_INVALID_CMD; |
1285 | 1285 |
1286 if (src >= src_end) | 1286 if (src >= src_end) |
1287 { | 1287 { |
1288 src++; | 1288 src++; |
1289 goto ccl_read_multibyte_character_suspend; | |
1290 } | |
1291 | |
1292 i = *src++; | |
1293 if (i < 0x80) | |
1294 { | |
1295 /* ASCII */ | |
1296 reg[rrr] = i; | |
1297 reg[RRR] = LEADING_BYTE_ASCII; | |
1298 } | |
1299 else if (i <= MAX_LEADING_BYTE_OFFICIAL_1) | |
1300 { | |
1301 if (src >= src_end) | |
1302 goto ccl_read_multibyte_character_suspend; | 1289 goto ccl_read_multibyte_character_suspend; |
1303 reg[RRR] = i; | 1290 } |
1304 reg[rrr] = (*src++ & 0x7F); | 1291 |
1305 } | 1292 i = *src++; |
1306 else if (i <= MAX_LEADING_BYTE_OFFICIAL_2) | 1293 if (i < 0x80) |
1307 { | 1294 { |
1308 if ((src + 1) >= src_end) | 1295 /* ASCII */ |
1309 goto ccl_read_multibyte_character_suspend; | 1296 reg[rrr] = i; |
1310 reg[RRR] = i; | 1297 reg[RRR] = LEADING_BYTE_ASCII; |
1311 i = (*src++ & 0x7F); | 1298 } |
1312 reg[rrr] = ((i << 7) | (*src & 0x7F)); | 1299 else if (i <= MAX_LEADING_BYTE_OFFICIAL_1) |
1313 src++; | 1300 { |
1314 } | 1301 if (src >= src_end) |
1315 else if (i == PRE_LEADING_BYTE_PRIVATE_1) | 1302 goto ccl_read_multibyte_character_suspend; |
1316 { | 1303 reg[RRR] = i; |
1317 if ((src + 1) >= src_end) | 1304 reg[rrr] = (*src++ & 0x7F); |
1318 goto ccl_read_multibyte_character_suspend; | 1305 } |
1319 reg[RRR] = *src++; | 1306 else if (i <= MAX_LEADING_BYTE_OFFICIAL_2) |
1320 reg[rrr] = (*src++ & 0x7F); | 1307 { |
1321 } | 1308 if ((src + 1) >= src_end) |
1322 else if (i == PRE_LEADING_BYTE_PRIVATE_2) | 1309 goto ccl_read_multibyte_character_suspend; |
1323 { | 1310 reg[RRR] = i; |
1324 if ((src + 2) >= src_end) | 1311 i = (*src++ & 0x7F); |
1325 goto ccl_read_multibyte_character_suspend; | 1312 reg[rrr] = ((i << 7) | (*src & 0x7F)); |
1326 reg[RRR] = *src++; | 1313 src++; |
1327 i = (*src++ & 0x7F); | 1314 } |
1328 reg[rrr] = ((i << 7) | (*src & 0x7F)); | 1315 else if (i == PRE_LEADING_BYTE_PRIVATE_1) |
1329 src++; | 1316 { |
1330 } | 1317 if ((src + 1) >= src_end) |
1331 else | 1318 goto ccl_read_multibyte_character_suspend; |
1332 { | 1319 reg[RRR] = *src++; |
1333 /* INVALID CODE. Return a single byte character. */ | 1320 reg[rrr] = (*src++ & 0x7F); |
1334 reg[RRR] = LEADING_BYTE_ASCII; | 1321 } |
1335 reg[rrr] = i; | 1322 else if (i == PRE_LEADING_BYTE_PRIVATE_2) |
1336 } | 1323 { |
1324 if ((src + 2) >= src_end) | |
1325 goto ccl_read_multibyte_character_suspend; | |
1326 reg[RRR] = *src++; | |
1327 i = (*src++ & 0x7F); | |
1328 reg[rrr] = ((i << 7) | (*src & 0x7F)); | |
1329 src++; | |
1330 } | |
1331 else | |
1332 { | |
1333 /* INVALID CODE. Return a single byte character. */ | |
1334 reg[RRR] = LEADING_BYTE_ASCII; | |
1335 reg[rrr] = i; | |
1336 } | |
1337 break; | 1337 break; |
1338 | 1338 |
1339 ccl_read_multibyte_character_suspend: | 1339 ccl_read_multibyte_character_suspend: |
1340 src--; | 1340 src--; |
1341 if (ccl->last_block) | 1341 if (ccl->last_block) |