diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-19 14:20:22 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-19 14:20:22 +0000 |
commit | 8971cdaeca82c8f8f2dc9257fc10c558d2cc77ff (patch) | |
tree | 74cc735fc72a82b8101bc7124741bb0760f0a04b | |
parent | e40c04b82695c1cde8ad9ed1e2aa1756463d73a7 (diff) | |
download | busybox-w32-8971cdaeca82c8f8f2dc9257fc10c558d2cc77ff.tar.gz busybox-w32-8971cdaeca82c8f8f2dc9257fc10c558d2cc77ff.tar.bz2 busybox-w32-8971cdaeca82c8f8f2dc9257fc10c558d2cc77ff.zip |
stty: reduce #ifdef forest
-rw-r--r-- | coreutils/stty.c | 97 |
1 files changed, 45 insertions, 52 deletions
diff --git a/coreutils/stty.c b/coreutils/stty.c index 641bfb815..e60c4f589 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c | |||
@@ -765,6 +765,40 @@ end_option: | |||
765 | return EXIT_SUCCESS; | 765 | return EXIT_SUCCESS; |
766 | } | 766 | } |
767 | 767 | ||
768 | /* Save set_mode from #ifdef forest plague */ | ||
769 | #ifndef ONLCR | ||
770 | #define ONLCR 0 | ||
771 | #endif | ||
772 | #ifndef OCRNL | ||
773 | #define OCRNL 0 | ||
774 | #endif | ||
775 | #ifndef ONLRET | ||
776 | #define ONLRET 0 | ||
777 | #endif | ||
778 | #ifndef XCASE | ||
779 | #define XCASE 0 | ||
780 | #endif | ||
781 | #ifndef IXANY | ||
782 | #define IXANY 0 | ||
783 | #endif | ||
784 | #ifndef TABDLY | ||
785 | #define TABDLY 0 | ||
786 | #endif | ||
787 | #ifndef OXTABS | ||
788 | #define OXTABS 0 | ||
789 | #endif | ||
790 | #ifndef IUCLC | ||
791 | #define IUCLC 0 | ||
792 | #endif | ||
793 | #ifndef OLCUC | ||
794 | #define OLCUC 0 | ||
795 | #endif | ||
796 | #ifndef ECHOCTL | ||
797 | #define ECHOCTL 0 | ||
798 | #endif | ||
799 | #ifndef ECHOKE | ||
800 | #define ECHOKE 0 | ||
801 | #endif | ||
768 | 802 | ||
769 | static void | 803 | static void |
770 | set_mode(const struct mode_info *info, int reversed, struct termios *mode) | 804 | set_mode(const struct mode_info *info, int reversed, struct termios *mode) |
@@ -790,23 +824,10 @@ set_mode(const struct mode_info *info, int reversed, struct termios *mode) | |||
790 | } else if (info->name == stty_nl) { | 824 | } else if (info->name == stty_nl) { |
791 | if (reversed) { | 825 | if (reversed) { |
792 | mode->c_iflag = (mode->c_iflag | ICRNL) & ~INLCR & ~IGNCR; | 826 | mode->c_iflag = (mode->c_iflag | ICRNL) & ~INLCR & ~IGNCR; |
793 | mode->c_oflag = (mode->c_oflag | 827 | mode->c_oflag = (mode->c_oflag | ONLCR) & ~OCRNL & ~ONLRET; |
794 | #ifdef ONLCR | ||
795 | | ONLCR | ||
796 | #endif | ||
797 | ) | ||
798 | #ifdef OCRNL | ||
799 | & ~OCRNL | ||
800 | #endif | ||
801 | #ifdef ONLRET | ||
802 | & ~ONLRET | ||
803 | #endif | ||
804 | ; | ||
805 | } else { | 828 | } else { |
806 | mode->c_iflag = mode->c_iflag & ~ICRNL; | 829 | mode->c_iflag = mode->c_iflag & ~ICRNL; |
807 | #ifdef ONLCR | 830 | if (ONLCR) mode->c_oflag = mode->c_oflag & ~ONLCR; |
808 | mode->c_oflag = mode->c_oflag & ~ONLCR; | ||
809 | #endif | ||
810 | } | 831 | } |
811 | } else if (info->name == stty_ek) { | 832 | } else if (info->name == stty_ek) { |
812 | mode->c_cc[VERASE] = CERASE; | 833 | mode->c_cc[VERASE] = CERASE; |
@@ -853,42 +874,31 @@ set_mode(const struct mode_info *info, int reversed, struct termios *mode) | |||
853 | /* Raw mode */ | 874 | /* Raw mode */ |
854 | mode->c_iflag = 0; | 875 | mode->c_iflag = 0; |
855 | mode->c_oflag &= ~OPOST; | 876 | mode->c_oflag &= ~OPOST; |
856 | mode->c_lflag &= ~(ISIG | ICANON | 877 | mode->c_lflag &= ~(ISIG | ICANON | XCASE); |
857 | #ifdef XCASE | ||
858 | | XCASE | ||
859 | #endif | ||
860 | ); | ||
861 | mode->c_cc[VMIN] = 1; | 878 | mode->c_cc[VMIN] = 1; |
862 | mode->c_cc[VTIME] = 0; | 879 | mode->c_cc[VTIME] = 0; |
863 | } | 880 | } |
864 | } | 881 | } |
865 | #ifdef IXANY | 882 | else if (IXANY && info->name == decctlq) { |
866 | else if (info->name == decctlq) { | ||
867 | if (reversed) | 883 | if (reversed) |
868 | mode->c_iflag |= IXANY; | 884 | mode->c_iflag |= IXANY; |
869 | else | 885 | else |
870 | mode->c_iflag &= ~IXANY; | 886 | mode->c_iflag &= ~IXANY; |
871 | } | 887 | } |
872 | #endif | 888 | else if (TABDLY && info->name == stty_tabs) { |
873 | #ifdef TABDLY | ||
874 | else if (info->name == stty_tabs) { | ||
875 | if (reversed) | 889 | if (reversed) |
876 | mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB3; | 890 | mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB3; |
877 | else | 891 | else |
878 | mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB0; | 892 | mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB0; |
879 | } | 893 | } |
880 | #else | 894 | else if (OXTABS && info->name == stty_tabs) { |
881 | # ifdef OXTABS | ||
882 | else if (info->name == stty_tabs) { | ||
883 | if (reversed) | 895 | if (reversed) |
884 | mode->c_oflag = mode->c_oflag | OXTABS; | 896 | mode->c_oflag = mode->c_oflag | OXTABS; |
885 | else | 897 | else |
886 | mode->c_oflag = mode->c_oflag & ~OXTABS; | 898 | mode->c_oflag = mode->c_oflag & ~OXTABS; |
887 | } | 899 | } |
888 | # endif | 900 | else if (XCASE && IUCLC && OLCUC |
889 | #endif | 901 | && (info->name == stty_lcase || info->name == stty_LCASE)) { |
890 | #if defined(XCASE) && defined(IUCLC) && defined(OLCUC) | ||
891 | else if (info->name == stty_lcase || info->name == stty_LCASE) { | ||
892 | if (reversed) { | 902 | if (reversed) { |
893 | mode->c_lflag &= ~XCASE; | 903 | mode->c_lflag &= ~XCASE; |
894 | mode->c_iflag &= ~IUCLC; | 904 | mode->c_iflag &= ~IUCLC; |
@@ -899,31 +909,14 @@ set_mode(const struct mode_info *info, int reversed, struct termios *mode) | |||
899 | mode->c_oflag |= OLCUC; | 909 | mode->c_oflag |= OLCUC; |
900 | } | 910 | } |
901 | } | 911 | } |
902 | #endif | ||
903 | else if (info->name == stty_crt) | 912 | else if (info->name == stty_crt) |
904 | mode->c_lflag |= ECHOE | 913 | mode->c_lflag |= ECHOE | ECHOCTL | ECHOKE; |
905 | #ifdef ECHOCTL | ||
906 | | ECHOCTL | ||
907 | #endif | ||
908 | #ifdef ECHOKE | ||
909 | | ECHOKE | ||
910 | #endif | ||
911 | ; | ||
912 | else if (info->name == stty_dec) { | 914 | else if (info->name == stty_dec) { |
913 | mode->c_cc[VINTR] = 3; /* ^C */ | 915 | mode->c_cc[VINTR] = 3; /* ^C */ |
914 | mode->c_cc[VERASE] = 127; /* DEL */ | 916 | mode->c_cc[VERASE] = 127; /* DEL */ |
915 | mode->c_cc[VKILL] = 21; /* ^U */ | 917 | mode->c_cc[VKILL] = 21; /* ^U */ |
916 | mode->c_lflag |= ECHOE | 918 | mode->c_lflag |= ECHOE | ECHOCTL | ECHOKE; |
917 | #ifdef ECHOCTL | 919 | if (IXANY) mode->c_iflag &= ~IXANY; |
918 | | ECHOCTL | ||
919 | #endif | ||
920 | #ifdef ECHOKE | ||
921 | | ECHOKE | ||
922 | #endif | ||
923 | ; | ||
924 | #ifdef IXANY | ||
925 | mode->c_iflag &= ~IXANY; | ||
926 | #endif | ||
927 | } | 920 | } |
928 | } else if (reversed) | 921 | } else if (reversed) |
929 | *bitsp = *bitsp & ~((unsigned long)info->mask) & ~info->bits; | 922 | *bitsp = *bitsp & ~((unsigned long)info->mask) & ~info->bits; |