diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-11 16:02:36 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-11 16:02:36 +0000 |
commit | 2ea8c40e8f642ded3d68e99f0675ce2e7b8794ee (patch) | |
tree | b8f344ca1c79821453184c1ed080a5c5f1ca4274 /coreutils | |
parent | 4f95e5aab8d6a2d827d3fe937cf2c72229f6955e (diff) | |
download | busybox-w32-2ea8c40e8f642ded3d68e99f0675ce2e7b8794ee.tar.gz busybox-w32-2ea8c40e8f642ded3d68e99f0675ce2e7b8794ee.tar.bz2 busybox-w32-2ea8c40e8f642ded3d68e99f0675ce2e7b8794ee.zip |
stty: incorporate strings into struct instead of keeping pointers there.
static:
text data bss dec hex filename
767535 974 9420 777929 bdec9 busybox_old
767403 974 9420 777797 bde45 busybox_unstripped
dynamic -fpic:
text data bss dec hex filename
718954 14030 12032 745016 b5e38 busybox_old
720278 12534 12032 744844 b5d8c busybox_unstripped
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/stty.c | 208 |
1 files changed, 123 insertions, 85 deletions
diff --git a/coreutils/stty.c b/coreutils/stty.c index 8ad12e65e..06e3b0ed5 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c | |||
@@ -127,29 +127,6 @@ enum { | |||
127 | control, input, output, local, combination | 127 | control, input, output, local, combination |
128 | }; | 128 | }; |
129 | 129 | ||
130 | static const char evenp [] ALIGN1 = "evenp"; | ||
131 | static const char raw [] ALIGN1 = "raw"; | ||
132 | static const char stty_min [] ALIGN1 = "min"; | ||
133 | static const char stty_time [] ALIGN1 = "time"; | ||
134 | static const char stty_swtch[] ALIGN1 = "swtch"; | ||
135 | static const char stty_eol [] ALIGN1 = "eol"; | ||
136 | static const char stty_eof [] ALIGN1 = "eof"; | ||
137 | static const char parity [] ALIGN1 = "parity"; | ||
138 | static const char stty_oddp [] ALIGN1 = "oddp"; | ||
139 | static const char stty_nl [] ALIGN1 = "nl"; | ||
140 | static const char stty_ek [] ALIGN1 = "ek"; | ||
141 | static const char stty_sane [] ALIGN1 = "sane"; | ||
142 | static const char cbreak [] ALIGN1 = "cbreak"; | ||
143 | static const char stty_pass8[] ALIGN1 = "pass8"; | ||
144 | static const char litout [] ALIGN1 = "litout"; | ||
145 | static const char cooked [] ALIGN1 = "cooked"; | ||
146 | static const char decctlq [] ALIGN1 = "decctlq"; | ||
147 | static const char stty_tabs [] ALIGN1 = "tabs"; | ||
148 | static const char stty_lcase[] ALIGN1 = "lcase"; | ||
149 | static const char stty_LCASE[] ALIGN1 = "LCASE"; | ||
150 | static const char stty_crt [] ALIGN1 = "crt"; | ||
151 | static const char stty_dec [] ALIGN1 = "dec"; | ||
152 | |||
153 | /* Flags for 'struct mode_info' */ | 130 | /* Flags for 'struct mode_info' */ |
154 | #define SANE_SET 1 /* Set in 'sane' mode */ | 131 | #define SANE_SET 1 /* Set in 'sane' mode */ |
155 | #define SANE_UNSET 2 /* Unset in 'sane' mode */ | 132 | #define SANE_UNSET 2 /* Unset in 'sane' mode */ |
@@ -158,7 +135,7 @@ static const char stty_dec [] ALIGN1 = "dec"; | |||
158 | 135 | ||
159 | /* Each mode */ | 136 | /* Each mode */ |
160 | struct mode_info { | 137 | struct mode_info { |
161 | const char *const name; /* Name given on command line */ | 138 | const char name[9]; /* Name given on command line */ |
162 | const unsigned char type; /* Which structure element to change */ | 139 | const unsigned char type; /* Which structure element to change */ |
163 | const unsigned char flags; /* Setting and display options */ | 140 | const unsigned char flags; /* Setting and display options */ |
164 | /* were using short here, but ppc32 was unhappy: */ | 141 | /* were using short here, but ppc32 was unhappy: */ |
@@ -166,13 +143,59 @@ struct mode_info { | |||
166 | const tcflag_t bits; /* Bits to set for this mode */ | 143 | const tcflag_t bits; /* Bits to set for this mode */ |
167 | }; | 144 | }; |
168 | 145 | ||
169 | /* We can optimize it further by using name[8] instead of char *name */ | 146 | enum { |
170 | /* but beware of "if (info->name == evenp)" checks! */ | 147 | /* Must match mode_info[] order! */ |
171 | /* Need to replace them with "if (info == &mode_info[EVENP_INDX])" */ | 148 | IDX_evenp = 0, |
149 | IDX_parity, | ||
150 | IDX_oddp, | ||
151 | IDX_nl, | ||
152 | IDX_ek, | ||
153 | IDX_sane, | ||
154 | IDX_cooked, | ||
155 | IDX_raw, | ||
156 | IDX_pass8, | ||
157 | IDX_litout, | ||
158 | IDX_cbreak, | ||
159 | IDX_crt, | ||
160 | IDX_dec, | ||
161 | #ifdef IXANY | ||
162 | IDX_decctlq, | ||
163 | #endif | ||
164 | #if defined(TABDLY) || defined(OXTABS) | ||
165 | IDX_tabs, | ||
166 | #endif | ||
167 | #if defined(XCASE) && defined(IUCLC) && defined(OLCUC) | ||
168 | IDX_lcase, | ||
169 | IDX_LCASE, | ||
170 | #endif | ||
171 | }; | ||
172 | 172 | ||
173 | #define MI_ENTRY(N,T,F,B,M) { N, T, F, M, B } | 173 | #define MI_ENTRY(N,T,F,B,M) { N, T, F, M, B } |
174 | 174 | ||
175 | static const struct mode_info mode_info[] = { | 175 | static const struct mode_info mode_info[] = { |
176 | MI_ENTRY("evenp", combination, REV | OMIT, 0, 0 ), | ||
177 | MI_ENTRY("parity", combination, REV | OMIT, 0, 0 ), | ||
178 | MI_ENTRY("oddp", combination, REV | OMIT, 0, 0 ), | ||
179 | MI_ENTRY("nl", combination, REV | OMIT, 0, 0 ), | ||
180 | MI_ENTRY("ek", combination, OMIT, 0, 0 ), | ||
181 | MI_ENTRY("sane", combination, OMIT, 0, 0 ), | ||
182 | MI_ENTRY("cooked", combination, REV | OMIT, 0, 0 ), | ||
183 | MI_ENTRY("raw", combination, REV | OMIT, 0, 0 ), | ||
184 | MI_ENTRY("pass8", combination, REV | OMIT, 0, 0 ), | ||
185 | MI_ENTRY("litout", combination, REV | OMIT, 0, 0 ), | ||
186 | MI_ENTRY("cbreak", combination, REV | OMIT, 0, 0 ), | ||
187 | MI_ENTRY("crt", combination, OMIT, 0, 0 ), | ||
188 | MI_ENTRY("dec", combination, OMIT, 0, 0 ), | ||
189 | #ifdef IXANY | ||
190 | MI_ENTRY("decctlq", combination, REV | OMIT, 0, 0 ), | ||
191 | #endif | ||
192 | #if defined(TABDLY) || defined(OXTABS) | ||
193 | MI_ENTRY("tabs", combination, REV | OMIT, 0, 0 ), | ||
194 | #endif | ||
195 | #if defined(XCASE) && defined(IUCLC) && defined(OLCUC) | ||
196 | MI_ENTRY("lcase", combination, REV | OMIT, 0, 0 ), | ||
197 | MI_ENTRY("LCASE", combination, REV | OMIT, 0, 0 ), | ||
198 | #endif | ||
176 | MI_ENTRY("parenb", control, REV, PARENB, 0 ), | 199 | MI_ENTRY("parenb", control, REV, PARENB, 0 ), |
177 | MI_ENTRY("parodd", control, REV, PARODD, 0 ), | 200 | MI_ENTRY("parodd", control, REV, PARODD, 0 ), |
178 | MI_ENTRY("cs5", control, 0, CS5, CSIZE), | 201 | MI_ENTRY("cs5", control, 0, CS5, CSIZE), |
@@ -293,56 +316,70 @@ static const struct mode_info mode_info[] = { | |||
293 | MI_ENTRY("echoke", local, SANE_SET | REV, ECHOKE, 0 ), | 316 | MI_ENTRY("echoke", local, SANE_SET | REV, ECHOKE, 0 ), |
294 | MI_ENTRY("crtkill", local, REV | OMIT, ECHOKE, 0 ), | 317 | MI_ENTRY("crtkill", local, REV | OMIT, ECHOKE, 0 ), |
295 | #endif | 318 | #endif |
296 | MI_ENTRY(evenp, combination, REV | OMIT, 0, 0 ), | ||
297 | MI_ENTRY(parity, combination, REV | OMIT, 0, 0 ), | ||
298 | MI_ENTRY(stty_oddp, combination, REV | OMIT, 0, 0 ), | ||
299 | MI_ENTRY(stty_nl, combination, REV | OMIT, 0, 0 ), | ||
300 | MI_ENTRY(stty_ek, combination, OMIT, 0, 0 ), | ||
301 | MI_ENTRY(stty_sane, combination, OMIT, 0, 0 ), | ||
302 | MI_ENTRY(cooked, combination, REV | OMIT, 0, 0 ), | ||
303 | MI_ENTRY(raw, combination, REV | OMIT, 0, 0 ), | ||
304 | MI_ENTRY(stty_pass8, combination, REV | OMIT, 0, 0 ), | ||
305 | MI_ENTRY(litout, combination, REV | OMIT, 0, 0 ), | ||
306 | MI_ENTRY(cbreak, combination, REV | OMIT, 0, 0 ), | ||
307 | #ifdef IXANY | ||
308 | MI_ENTRY(decctlq, combination, REV | OMIT, 0, 0 ), | ||
309 | #endif | ||
310 | #if defined(TABDLY) || defined(OXTABS) | ||
311 | MI_ENTRY(stty_tabs, combination, REV | OMIT, 0, 0 ), | ||
312 | #endif | ||
313 | #if defined(XCASE) && defined(IUCLC) && defined(OLCUC) | ||
314 | MI_ENTRY(stty_lcase, combination, REV | OMIT, 0, 0 ), | ||
315 | MI_ENTRY(stty_LCASE, combination, REV | OMIT, 0, 0 ), | ||
316 | #endif | ||
317 | MI_ENTRY(stty_crt, combination, OMIT, 0, 0 ), | ||
318 | MI_ENTRY(stty_dec, combination, OMIT, 0, 0 ), | ||
319 | }; | 319 | }; |
320 | 320 | ||
321 | enum { | 321 | enum { |
322 | NUM_mode_info = ARRAY_SIZE(mode_info) | 322 | NUM_mode_info = ARRAY_SIZE(mode_info) |
323 | }; | 323 | }; |
324 | 324 | ||
325 | /* Control character settings */ | 325 | /* Control characters */ |
326 | struct control_info { | 326 | struct control_info { |
327 | const char *const name; /* Name given on command line */ | 327 | const char name[7]; /* Name given on command line */ |
328 | const unsigned char saneval; /* Value to set for 'stty sane' */ | 328 | const unsigned char saneval; /* Value to set for 'stty sane' */ |
329 | const unsigned char offset; /* Offset in c_cc */ | 329 | const unsigned char offset; /* Offset in c_cc */ |
330 | }; | 330 | }; |
331 | 331 | ||
332 | /* Control characters */ | 332 | enum { |
333 | /* Must match control_info[] order! */ | ||
334 | CIDX_intr = 0, | ||
335 | CIDX_quit, | ||
336 | CIDX_erase, | ||
337 | CIDX_kill, | ||
338 | CIDX_eof, | ||
339 | CIDX_eol, | ||
340 | #ifdef VEOL2 | ||
341 | CIDX_eol2, | ||
342 | #endif | ||
343 | #ifdef VSWTCH | ||
344 | CIDX_swtch, | ||
345 | #endif | ||
346 | CIDX_start, | ||
347 | CIDX_stop, | ||
348 | CIDX_susp, | ||
349 | #ifdef VDSUSP | ||
350 | CIDX_dsusp, | ||
351 | #endif | ||
352 | #ifdef VREPRINT | ||
353 | CIDX_rprnt, | ||
354 | #endif | ||
355 | #ifdef VWERASE | ||
356 | CIDX_werase, | ||
357 | #endif | ||
358 | #ifdef VLNEXT | ||
359 | CIDX_lnext, | ||
360 | #endif | ||
361 | #ifdef VFLUSHO | ||
362 | CIDX_flush, | ||
363 | #endif | ||
364 | #ifdef VSTATUS | ||
365 | CIDX_status, | ||
366 | #endif | ||
367 | CIDX_min, | ||
368 | CIDX_time, | ||
369 | }; | ||
333 | 370 | ||
334 | static const struct control_info control_info[] = { | 371 | static const struct control_info control_info[] = { |
335 | {"intr", CINTR, VINTR}, | 372 | {"intr", CINTR, VINTR}, |
336 | {"quit", CQUIT, VQUIT}, | 373 | {"quit", CQUIT, VQUIT}, |
337 | {"erase", CERASE, VERASE}, | 374 | {"erase", CERASE, VERASE}, |
338 | {"kill", CKILL, VKILL}, | 375 | {"kill", CKILL, VKILL}, |
339 | {stty_eof, CEOF, VEOF}, | 376 | {"eof", CEOF, VEOF}, |
340 | {stty_eol, CEOL, VEOL}, | 377 | {"eol", CEOL, VEOL}, |
341 | #ifdef VEOL2 | 378 | #ifdef VEOL2 |
342 | {"eol2", CEOL2, VEOL2}, | 379 | {"eol2", CEOL2, VEOL2}, |
343 | #endif | 380 | #endif |
344 | #ifdef VSWTCH | 381 | #ifdef VSWTCH |
345 | {stty_swtch, CSWTCH, VSWTCH}, | 382 | {"swtch", CSWTCH, VSWTCH}, |
346 | #endif | 383 | #endif |
347 | {"start", CSTART, VSTART}, | 384 | {"start", CSTART, VSTART}, |
348 | {"stop", CSTOP, VSTOP}, | 385 | {"stop", CSTOP, VSTOP}, |
@@ -366,8 +403,8 @@ static const struct control_info control_info[] = { | |||
366 | {"status", CSTATUS, VSTATUS}, | 403 | {"status", CSTATUS, VSTATUS}, |
367 | #endif | 404 | #endif |
368 | /* These must be last because of the display routines */ | 405 | /* These must be last because of the display routines */ |
369 | {stty_min, 1, VMIN}, | 406 | {"min", 1, VMIN}, |
370 | {stty_time, 0, VTIME}, | 407 | {"time", 0, VTIME}, |
371 | }; | 408 | }; |
372 | 409 | ||
373 | enum { | 410 | enum { |
@@ -653,17 +690,19 @@ static void do_display(const struct termios *mode, const int all) | |||
653 | wrapf("\n"); | 690 | wrapf("\n"); |
654 | #endif | 691 | #endif |
655 | 692 | ||
656 | for (i = 0; control_info[i].name != stty_min; ++i) { | 693 | for (i = 0; i != CIDX_min; ++i) { |
657 | /* If swtch is the same as susp, don't print both */ | 694 | /* If swtch is the same as susp, don't print both */ |
658 | #if VSWTCH == VSUSP | 695 | #if VSWTCH == VSUSP |
659 | if (control_info[i].name == stty_swtch) | 696 | if (i == CIDX_swtch) |
660 | continue; | 697 | continue; |
661 | #endif | 698 | #endif |
662 | /* If eof uses the same slot as min, only print whichever applies */ | 699 | /* If eof uses the same slot as min, only print whichever applies */ |
663 | #if VEOF == VMIN | 700 | #if VEOF == VMIN |
664 | if ((mode->c_lflag & ICANON) == 0 | 701 | if ((mode->c_lflag & ICANON) == 0 |
665 | && (control_info[i].name == stty_eof | 702 | && (i == CIDX_eof || i == CIDX_eol) |
666 | || control_info[i].name == stty_eol)) continue; | 703 | ) { |
704 | continue; | ||
705 | } | ||
667 | #endif | 706 | #endif |
668 | wrapf("%s = %s;", control_info[i].name, | 707 | wrapf("%s = %s;", control_info[i].name, |
669 | visible(mode->c_cc[control_info[i].offset])); | 708 | visible(mode->c_cc[control_info[i].offset])); |
@@ -705,7 +744,7 @@ static void sane_mode(struct termios *mode) | |||
705 | 744 | ||
706 | for (i = 0; i < NUM_control_info; ++i) { | 745 | for (i = 0; i < NUM_control_info; ++i) { |
707 | #if VMIN == VEOF | 746 | #if VMIN == VEOF |
708 | if (control_info[i].name == stty_min) | 747 | if (i == CIDX_min) |
709 | break; | 748 | break; |
710 | #endif | 749 | #endif |
711 | mode->c_cc[control_info[i].offset] = control_info[i].saneval; | 750 | mode->c_cc[control_info[i].offset] = control_info[i].saneval; |
@@ -775,17 +814,17 @@ static void set_mode(const struct mode_info *info, int reversed, | |||
775 | } | 814 | } |
776 | 815 | ||
777 | /* Combination mode */ | 816 | /* Combination mode */ |
778 | if (info->name == evenp || info->name == parity) { | 817 | if (info == &mode_info[IDX_evenp] || info == &mode_info[IDX_parity]) { |
779 | if (reversed) | 818 | if (reversed) |
780 | mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; | 819 | mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; |
781 | else | 820 | else |
782 | mode->c_cflag = (mode->c_cflag & ~PARODD & ~CSIZE) | PARENB | CS7; | 821 | mode->c_cflag = (mode->c_cflag & ~PARODD & ~CSIZE) | PARENB | CS7; |
783 | } else if (info->name == stty_oddp) { | 822 | } else if (info == &mode_info[IDX_oddp]) { |
784 | if (reversed) | 823 | if (reversed) |
785 | mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; | 824 | mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; |
786 | else | 825 | else |
787 | mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARODD | PARENB; | 826 | mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARODD | PARENB; |
788 | } else if (info->name == stty_nl) { | 827 | } else if (info == &mode_info[IDX_nl]) { |
789 | if (reversed) { | 828 | if (reversed) { |
790 | mode->c_iflag = (mode->c_iflag | ICRNL) & ~INLCR & ~IGNCR; | 829 | mode->c_iflag = (mode->c_iflag | ICRNL) & ~INLCR & ~IGNCR; |
791 | mode->c_oflag = (mode->c_oflag | ONLCR) & ~OCRNL & ~ONLRET; | 830 | mode->c_oflag = (mode->c_oflag | ONLCR) & ~OCRNL & ~ONLRET; |
@@ -793,18 +832,17 @@ static void set_mode(const struct mode_info *info, int reversed, | |||
793 | mode->c_iflag = mode->c_iflag & ~ICRNL; | 832 | mode->c_iflag = mode->c_iflag & ~ICRNL; |
794 | if (ONLCR) mode->c_oflag = mode->c_oflag & ~ONLCR; | 833 | if (ONLCR) mode->c_oflag = mode->c_oflag & ~ONLCR; |
795 | } | 834 | } |
796 | } else if (info->name == stty_ek) { | 835 | } else if (info == &mode_info[IDX_ek]) { |
797 | mode->c_cc[VERASE] = CERASE; | 836 | mode->c_cc[VERASE] = CERASE; |
798 | mode->c_cc[VKILL] = CKILL; | 837 | mode->c_cc[VKILL] = CKILL; |
799 | } else if (info->name == stty_sane) { | 838 | } else if (info == &mode_info[IDX_sane]) { |
800 | sane_mode(mode); | 839 | sane_mode(mode); |
801 | } | 840 | } else if (info == &mode_info[IDX_cbreak]) { |
802 | else if (info->name == cbreak) { | ||
803 | if (reversed) | 841 | if (reversed) |
804 | mode->c_lflag |= ICANON; | 842 | mode->c_lflag |= ICANON; |
805 | else | 843 | else |
806 | mode->c_lflag &= ~ICANON; | 844 | mode->c_lflag &= ~ICANON; |
807 | } else if (info->name == stty_pass8) { | 845 | } else if (info == &mode_info[IDX_pass8]) { |
808 | if (reversed) { | 846 | if (reversed) { |
809 | mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; | 847 | mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; |
810 | mode->c_iflag |= ISTRIP; | 848 | mode->c_iflag |= ISTRIP; |
@@ -812,7 +850,7 @@ static void set_mode(const struct mode_info *info, int reversed, | |||
812 | mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; | 850 | mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; |
813 | mode->c_iflag &= ~ISTRIP; | 851 | mode->c_iflag &= ~ISTRIP; |
814 | } | 852 | } |
815 | } else if (info->name == litout) { | 853 | } else if (info == &mode_info[IDX_litout]) { |
816 | if (reversed) { | 854 | if (reversed) { |
817 | mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; | 855 | mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; |
818 | mode->c_iflag |= ISTRIP; | 856 | mode->c_iflag |= ISTRIP; |
@@ -822,9 +860,10 @@ static void set_mode(const struct mode_info *info, int reversed, | |||
822 | mode->c_iflag &= ~ISTRIP; | 860 | mode->c_iflag &= ~ISTRIP; |
823 | mode->c_oflag &= ~OPOST; | 861 | mode->c_oflag &= ~OPOST; |
824 | } | 862 | } |
825 | } else if (info->name == raw || info->name == cooked) { | 863 | } else if (info == &mode_info[IDX_raw] || info == &mode_info[IDX_cooked]) { |
826 | if ((info->name[0] == 'r' && reversed) | 864 | if ((info->name[0] == 'r' && reversed) |
827 | || (info->name[0] == 'c' && !reversed)) { | 865 | || (info->name[0] == 'c' && !reversed) |
866 | ) { | ||
828 | /* Cooked mode */ | 867 | /* Cooked mode */ |
829 | mode->c_iflag |= BRKINT | IGNPAR | ISTRIP | ICRNL | IXON; | 868 | mode->c_iflag |= BRKINT | IGNPAR | ISTRIP | ICRNL | IXON; |
830 | mode->c_oflag |= OPOST; | 869 | mode->c_oflag |= OPOST; |
@@ -844,26 +883,27 @@ static void set_mode(const struct mode_info *info, int reversed, | |||
844 | mode->c_cc[VTIME] = 0; | 883 | mode->c_cc[VTIME] = 0; |
845 | } | 884 | } |
846 | } | 885 | } |
847 | else if (IXANY && info->name == decctlq) { | 886 | else if (IXANY && info == &mode_info[IDX_decctlq]) { |
848 | if (reversed) | 887 | if (reversed) |
849 | mode->c_iflag |= IXANY; | 888 | mode->c_iflag |= IXANY; |
850 | else | 889 | else |
851 | mode->c_iflag &= ~IXANY; | 890 | mode->c_iflag &= ~IXANY; |
852 | } | 891 | } |
853 | else if (TABDLY && info->name == stty_tabs) { | 892 | else if (TABDLY && info == &mode_info[IDX_tabs]) { |
854 | if (reversed) | 893 | if (reversed) |
855 | mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB3; | 894 | mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB3; |
856 | else | 895 | else |
857 | mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB0; | 896 | mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB0; |
858 | } | 897 | } |
859 | else if (OXTABS && info->name == stty_tabs) { | 898 | else if (OXTABS && info == &mode_info[IDX_tabs]) { |
860 | if (reversed) | 899 | if (reversed) |
861 | mode->c_oflag |= OXTABS; | 900 | mode->c_oflag |= OXTABS; |
862 | else | 901 | else |
863 | mode->c_oflag &= ~OXTABS; | 902 | mode->c_oflag &= ~OXTABS; |
864 | } | 903 | } else |
865 | else if (XCASE && IUCLC && OLCUC | 904 | if (XCASE && IUCLC && OLCUC |
866 | && (info->name == stty_lcase || info->name == stty_LCASE)) { | 905 | && (info == &mode_info[IDX_lcase] || info == &mode_info[IDX_LCASE]) |
906 | ) { | ||
867 | if (reversed) { | 907 | if (reversed) { |
868 | mode->c_lflag &= ~XCASE; | 908 | mode->c_lflag &= ~XCASE; |
869 | mode->c_iflag &= ~IUCLC; | 909 | mode->c_iflag &= ~IUCLC; |
@@ -873,11 +913,9 @@ static void set_mode(const struct mode_info *info, int reversed, | |||
873 | mode->c_iflag |= IUCLC; | 913 | mode->c_iflag |= IUCLC; |
874 | mode->c_oflag |= OLCUC; | 914 | mode->c_oflag |= OLCUC; |
875 | } | 915 | } |
876 | } | 916 | } else if (info == &mode_info[IDX_crt]) { |
877 | else if (info->name == stty_crt) { | ||
878 | mode->c_lflag |= ECHOE | ECHOCTL | ECHOKE; | 917 | mode->c_lflag |= ECHOE | ECHOCTL | ECHOKE; |
879 | } | 918 | } else if (info == &mode_info[IDX_dec]) { |
880 | else if (info->name == stty_dec) { | ||
881 | mode->c_cc[VINTR] = 3; /* ^C */ | 919 | mode->c_cc[VINTR] = 3; /* ^C */ |
882 | mode->c_cc[VERASE] = 127; /* DEL */ | 920 | mode->c_cc[VERASE] = 127; /* DEL */ |
883 | mode->c_cc[VKILL] = 21; /* ^U */ | 921 | mode->c_cc[VKILL] = 21; /* ^U */ |
@@ -891,7 +929,7 @@ static void set_control_char_or_die(const struct control_info *info, | |||
891 | { | 929 | { |
892 | unsigned char value; | 930 | unsigned char value; |
893 | 931 | ||
894 | if (info->name == stty_min || info->name == stty_time) | 932 | if (info == &control_info[CIDX_min] || info == &control_info[CIDX_time]) |
895 | value = xatoul_range_sfx(arg, 0, 0xff, stty_suffixes); | 933 | value = xatoul_range_sfx(arg, 0, 0xff, stty_suffixes); |
896 | else if (arg[0] == '\0' || arg[1] == '\0') | 934 | else if (arg[0] == '\0' || arg[1] == '\0') |
897 | value = arg[0]; | 935 | value = arg[0]; |