comparison src/ccl.c @ 40940:174ef035d156

Change macros to use do-while block instead of if-else. Use braces to follow GNU Coding Standards.
author Pavel Janík <Pavel@Janik.cz>
date Mon, 12 Nov 2001 07:28:40 +0000
parents cdfd4d09b79a
children 2c3898d7bbef
comparison
equal deleted inserted replaced
40939:d43f115e0456 40940:174ef035d156
599 /* If this variable is non-zero, it indicates the stack_idx 599 /* If this variable is non-zero, it indicates the stack_idx
600 of immediately called by CCL_MapMultiple. */ 600 of immediately called by CCL_MapMultiple. */
601 static int stack_idx_of_map_multiple; 601 static int stack_idx_of_map_multiple;
602 602
603 #define PUSH_MAPPING_STACK(restlen, orig) \ 603 #define PUSH_MAPPING_STACK(restlen, orig) \
604 do { \ 604 do \
605 { \
605 mapping_stack_pointer->rest_length = (restlen); \ 606 mapping_stack_pointer->rest_length = (restlen); \
606 mapping_stack_pointer->orig_val = (orig); \ 607 mapping_stack_pointer->orig_val = (orig); \
607 mapping_stack_pointer++; \ 608 mapping_stack_pointer++; \
608 } while (0) 609 } \
610 while (0)
609 611
610 #define POP_MAPPING_STACK(restlen, orig) \ 612 #define POP_MAPPING_STACK(restlen, orig) \
611 do { \ 613 do \
614 { \
612 mapping_stack_pointer--; \ 615 mapping_stack_pointer--; \
613 (restlen) = mapping_stack_pointer->rest_length; \ 616 (restlen) = mapping_stack_pointer->rest_length; \
614 (orig) = mapping_stack_pointer->orig_val; \ 617 (orig) = mapping_stack_pointer->orig_val; \
615 } while (0) 618 } \
619 while (0)
616 620
617 #define CCL_CALL_FOR_MAP_INSTRUCTION(symbol, ret_ic) \ 621 #define CCL_CALL_FOR_MAP_INSTRUCTION(symbol, ret_ic) \
618 if (1) \ 622 do \
619 { \ 623 { \
620 struct ccl_program called_ccl; \ 624 struct ccl_program called_ccl; \
621 if (stack_idx >= 256 \ 625 if (stack_idx >= 256 \
622 || (setup_ccl_program (&called_ccl, (symbol)) != 0)) \ 626 || (setup_ccl_program (&called_ccl, (symbol)) != 0)) \
623 { \ 627 { \
633 stack_idx++; \ 637 stack_idx++; \
634 ccl_prog = called_ccl.prog; \ 638 ccl_prog = called_ccl.prog; \
635 ic = CCL_HEADER_MAIN; \ 639 ic = CCL_HEADER_MAIN; \
636 goto ccl_repeat; \ 640 goto ccl_repeat; \
637 } \ 641 } \
638 else 642 while (0)
639 643
640 #define CCL_MapSingle 0x12 /* Map by single code conversion map 644 #define CCL_MapSingle 0x12 /* Map by single code conversion map
641 1:ExtendedCOMMNDXXXRRRrrrXXXXX 645 1:ExtendedCOMMNDXXXRRRrrrXXXXX
642 2:MAP-ID 646 2:MAP-ID
643 ------------------------------ 647 ------------------------------
674 #define CCL_ENCODE_SJIS 0x17 /* X = HIGHER_BYTE (SJIS (Y, Z)) 678 #define CCL_ENCODE_SJIS 0x17 /* X = HIGHER_BYTE (SJIS (Y, Z))
675 r[7] = LOWER_BYTE (SJIS (Y, Z) */ 679 r[7] = LOWER_BYTE (SJIS (Y, Z) */
676 680
677 /* Terminate CCL program successfully. */ 681 /* Terminate CCL program successfully. */
678 #define CCL_SUCCESS \ 682 #define CCL_SUCCESS \
679 if (1) \ 683 do \
680 { \ 684 { \
681 ccl->status = CCL_STAT_SUCCESS; \ 685 ccl->status = CCL_STAT_SUCCESS; \
682 goto ccl_finish; \ 686 goto ccl_finish; \
683 } \ 687 } \
684 else 688 while(0)
685 689
686 /* Suspend CCL program because of reading from empty input buffer or 690 /* Suspend CCL program because of reading from empty input buffer or
687 writing to full output buffer. When this program is resumed, the 691 writing to full output buffer. When this program is resumed, the
688 same I/O command is executed. */ 692 same I/O command is executed. */
689 #define CCL_SUSPEND(stat) \ 693 #define CCL_SUSPEND(stat) \
690 if (1) \ 694 do \
691 { \ 695 { \
692 ic--; \ 696 ic--; \
693 ccl->status = stat; \ 697 ccl->status = stat; \
694 goto ccl_finish; \ 698 goto ccl_finish; \
695 } \ 699 } \
696 else 700 while (0)
697 701
698 /* Terminate CCL program because of invalid command. Should not occur 702 /* Terminate CCL program because of invalid command. Should not occur
699 in the normal case. */ 703 in the normal case. */
700 #define CCL_INVALID_CMD \ 704 #define CCL_INVALID_CMD \
701 if (1) \ 705 do \
702 { \ 706 { \
703 ccl->status = CCL_STAT_INVALID_CMD; \ 707 ccl->status = CCL_STAT_INVALID_CMD; \
704 goto ccl_error_handler; \ 708 goto ccl_error_handler; \
705 } \ 709 } \
706 else 710 while(0)
707 711
708 /* Encode one character CH to multibyte form and write to the current 712 /* Encode one character CH to multibyte form and write to the current
709 output buffer. If CH is less than 256, CH is written as is. */ 713 output buffer. If CH is less than 256, CH is written as is. */
710 #define CCL_WRITE_CHAR(ch) \ 714 #define CCL_WRITE_CHAR(ch) \
711 do { \ 715 do { \