aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-01-11 16:35:52 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2017-01-11 16:35:52 +0100
commited15dde60a72dce888df10295a916b199346929d (patch)
treee3d9fab96ea62f20f29460de32e8cacaab9d2267
parent6c1f348fa792a33d5a98e68c139df65c2d4c1628 (diff)
downloadbusybox-w32-ed15dde60a72dce888df10295a916b199346929d.tar.gz
busybox-w32-ed15dde60a72dce888df10295a916b199346929d.tar.bz2
busybox-w32-ed15dde60a72dce888df10295a916b199346929d.zip
Move FEATURE_AUTOWIDTH config option to two applets which use it
No code changes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--Config.in11
-rw-r--r--configs/TEST_nommu_defconfig5
-rw-r--r--configs/TEST_noprintf_defconfig1
-rw-r--r--configs/TEST_rh9_defconfig5
-rw-r--r--configs/android2_defconfig5
-rw-r--r--configs/android_502_defconfig5
-rw-r--r--configs/android_defconfig5
-rw-r--r--configs/android_ndk_defconfig5
-rw-r--r--configs/cygwin_defconfig5
-rw-r--r--configs/freebsd_defconfig5
-rw-r--r--coreutils/ls.c27
-rw-r--r--networking/telnet.c15
12 files changed, 26 insertions, 68 deletions
diff --git a/Config.in b/Config.in
index ec302ffdf..cfb3aa0ee 100644
--- a/Config.in
+++ b/Config.in
@@ -50,17 +50,6 @@ config USE_PORTABLE_CODE
50 compiler other than gcc. 50 compiler other than gcc.
51 If you do use gcc, this option may needlessly increase code size. 51 If you do use gcc, this option may needlessly increase code size.
52 52
53#fixme: delete, create suboptions for applets which use this
54config FEATURE_AUTOWIDTH
55 bool "Calculate terminal & column widths"
56 default y
57 help
58 This option allows utilities such as 'ls', 'telnet' etc
59 to determine the width of the screen, which can allow them to
60 display additional text or avoid wrapping text onto the next line.
61 If you leave this disabled, your utilities will be especially
62 primitive and will be unable to determine the current screen width.
63
64config SHOW_USAGE 53config SHOW_USAGE
65 bool "Show applet usage messages" 54 bool "Show applet usage messages"
66 default y 55 default y
diff --git a/configs/TEST_nommu_defconfig b/configs/TEST_nommu_defconfig
index 37f3df019..b7d9a35c2 100644
--- a/configs/TEST_nommu_defconfig
+++ b/configs/TEST_nommu_defconfig
@@ -266,11 +266,6 @@ CONFIG_YES=y
266CONFIG_FEATURE_PRESERVE_HARDLINKS=y 266CONFIG_FEATURE_PRESERVE_HARDLINKS=y
267 267
268# 268#
269# Common options for ls, more and telnet
270#
271CONFIG_FEATURE_AUTOWIDTH=y
272
273#
274# Common options for df, du, ls 269# Common options for df, du, ls
275# 270#
276CONFIG_FEATURE_HUMAN_READABLE=y 271CONFIG_FEATURE_HUMAN_READABLE=y
diff --git a/configs/TEST_noprintf_defconfig b/configs/TEST_noprintf_defconfig
index b03f6250e..3f85ee1df 100644
--- a/configs/TEST_noprintf_defconfig
+++ b/configs/TEST_noprintf_defconfig
@@ -277,7 +277,6 @@ CONFIG_TRUE=y
277# CONFIG_WHOAMI is not set 277# CONFIG_WHOAMI is not set
278# CONFIG_YES is not set 278# CONFIG_YES is not set
279# CONFIG_FEATURE_PRESERVE_HARDLINKS is not set 279# CONFIG_FEATURE_PRESERVE_HARDLINKS is not set
280# CONFIG_FEATURE_AUTOWIDTH is not set
281# CONFIG_FEATURE_HUMAN_READABLE is not set 280# CONFIG_FEATURE_HUMAN_READABLE is not set
282# CONFIG_FEATURE_MD5_SHA1_SUM_CHECK is not set 281# CONFIG_FEATURE_MD5_SHA1_SUM_CHECK is not set
283 282
diff --git a/configs/TEST_rh9_defconfig b/configs/TEST_rh9_defconfig
index 3fc137787..99deb67fe 100644
--- a/configs/TEST_rh9_defconfig
+++ b/configs/TEST_rh9_defconfig
@@ -277,11 +277,6 @@ CONFIG_YES=y
277CONFIG_FEATURE_PRESERVE_HARDLINKS=y 277CONFIG_FEATURE_PRESERVE_HARDLINKS=y
278 278
279# 279#
280# Common options for ls, more and telnet
281#
282CONFIG_FEATURE_AUTOWIDTH=y
283
284#
285# Common options for df, du, ls 280# Common options for df, du, ls
286# 281#
287CONFIG_FEATURE_HUMAN_READABLE=y 282CONFIG_FEATURE_HUMAN_READABLE=y
diff --git a/configs/android2_defconfig b/configs/android2_defconfig
index 1846bb764..b079fa759 100644
--- a/configs/android2_defconfig
+++ b/configs/android2_defconfig
@@ -289,11 +289,6 @@ CONFIG_YES=y
289CONFIG_FEATURE_PRESERVE_HARDLINKS=y 289CONFIG_FEATURE_PRESERVE_HARDLINKS=y
290 290
291# 291#
292# Common options for ls, more and telnet
293#
294CONFIG_FEATURE_AUTOWIDTH=y
295
296#
297# Common options for df, du, ls 292# Common options for df, du, ls
298# 293#
299CONFIG_FEATURE_HUMAN_READABLE=y 294CONFIG_FEATURE_HUMAN_READABLE=y
diff --git a/configs/android_502_defconfig b/configs/android_502_defconfig
index 2cf4cd86c..4273d3382 100644
--- a/configs/android_502_defconfig
+++ b/configs/android_502_defconfig
@@ -390,11 +390,6 @@ CONFIG_FEATURE_VERBOSE=y
390CONFIG_FEATURE_PRESERVE_HARDLINKS=y 390CONFIG_FEATURE_PRESERVE_HARDLINKS=y
391 391
392# 392#
393# Common options for ls, more and telnet
394#
395CONFIG_FEATURE_AUTOWIDTH=y
396
397#
398# Common options for df, du, ls 393# Common options for df, du, ls
399# 394#
400CONFIG_FEATURE_HUMAN_READABLE=y 395CONFIG_FEATURE_HUMAN_READABLE=y
diff --git a/configs/android_defconfig b/configs/android_defconfig
index 8316b2efb..b9489c456 100644
--- a/configs/android_defconfig
+++ b/configs/android_defconfig
@@ -312,11 +312,6 @@ CONFIG_YES=y
312CONFIG_FEATURE_PRESERVE_HARDLINKS=y 312CONFIG_FEATURE_PRESERVE_HARDLINKS=y
313 313
314# 314#
315# Common options for ls, more and telnet
316#
317CONFIG_FEATURE_AUTOWIDTH=y
318
319#
320# Common options for df, du, ls 315# Common options for df, du, ls
321# 316#
322CONFIG_FEATURE_HUMAN_READABLE=y 317CONFIG_FEATURE_HUMAN_READABLE=y
diff --git a/configs/android_ndk_defconfig b/configs/android_ndk_defconfig
index d8b994ed4..caf22e57b 100644
--- a/configs/android_ndk_defconfig
+++ b/configs/android_ndk_defconfig
@@ -316,11 +316,6 @@ CONFIG_FEATURE_VERBOSE=y
316CONFIG_FEATURE_PRESERVE_HARDLINKS=y 316CONFIG_FEATURE_PRESERVE_HARDLINKS=y
317 317
318# 318#
319# Common options for ls, more and telnet
320#
321CONFIG_FEATURE_AUTOWIDTH=y
322
323#
324# Common options for df, du, ls 319# Common options for df, du, ls
325# 320#
326CONFIG_FEATURE_HUMAN_READABLE=y 321CONFIG_FEATURE_HUMAN_READABLE=y
diff --git a/configs/cygwin_defconfig b/configs/cygwin_defconfig
index 352ed90ad..6bfc973ef 100644
--- a/configs/cygwin_defconfig
+++ b/configs/cygwin_defconfig
@@ -289,11 +289,6 @@ CONFIG_YES=y
289CONFIG_FEATURE_PRESERVE_HARDLINKS=y 289CONFIG_FEATURE_PRESERVE_HARDLINKS=y
290 290
291# 291#
292# Common options for ls, more and telnet
293#
294CONFIG_FEATURE_AUTOWIDTH=y
295
296#
297# Common options for df, du, ls 292# Common options for df, du, ls
298# 293#
299CONFIG_FEATURE_HUMAN_READABLE=y 294CONFIG_FEATURE_HUMAN_READABLE=y
diff --git a/configs/freebsd_defconfig b/configs/freebsd_defconfig
index b19a9fd49..e3d04aedc 100644
--- a/configs/freebsd_defconfig
+++ b/configs/freebsd_defconfig
@@ -287,11 +287,6 @@ CONFIG_YES=y
287CONFIG_FEATURE_PRESERVE_HARDLINKS=y 287CONFIG_FEATURE_PRESERVE_HARDLINKS=y
288 288
289# 289#
290# Common options for ls, more and telnet
291#
292CONFIG_FEATURE_AUTOWIDTH=y
293
294#
295# Common options for df, du, ls 290# Common options for df, du, ls
296# 291#
297CONFIG_FEATURE_HUMAN_READABLE=y 292CONFIG_FEATURE_HUMAN_READABLE=y
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 531eb85b5..13df77410 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -48,6 +48,11 @@
48//config: default y 48//config: default y
49//config: depends on LS 49//config: depends on LS
50//config: 50//config:
51//config:config FEATURE_LS_WIDTH
52//config: bool "Enable -w WIDTH and window size autodetection"
53//config: default y
54//config: depends on LS
55//config:
51//config:config FEATURE_LS_SORTFILES 56//config:config FEATURE_LS_SORTFILES
52//config: bool "Sort the file names" 57//config: bool "Sort the file names"
53//config: default y 58//config: default y
@@ -101,7 +106,7 @@
101//usage: IF_FEATURE_LS_SORTFILES("rSXv") 106//usage: IF_FEATURE_LS_SORTFILES("rSXv")
102//usage: IF_FEATURE_LS_TIMESTAMPS("ctu") 107//usage: IF_FEATURE_LS_TIMESTAMPS("ctu")
103//usage: IF_SELINUX("kKZ") "]" 108//usage: IF_SELINUX("kKZ") "]"
104//usage: IF_FEATURE_AUTOWIDTH(" [-w WIDTH]") " [FILE]..." 109//usage: IF_FEATURE_LS_WIDTH(" [-w WIDTH]") " [FILE]..."
105//usage:#define ls_full_usage "\n\n" 110//usage:#define ls_full_usage "\n\n"
106//usage: "List directory contents\n" 111//usage: "List directory contents\n"
107//usage: "\n -1 One column output" 112//usage: "\n -1 One column output"
@@ -147,7 +152,7 @@
147//usage: "\n -K List security context in long format" 152//usage: "\n -K List security context in long format"
148//usage: "\n -Z List security context and permission" 153//usage: "\n -Z List security context and permission"
149//usage: ) 154//usage: )
150//usage: IF_FEATURE_AUTOWIDTH( 155//usage: IF_FEATURE_LS_WIDTH(
151//usage: "\n -w N Assume the terminal is N columns wide" 156//usage: "\n -w N Assume the terminal is N columns wide"
152//usage: ) 157//usage: )
153//usage: IF_FEATURE_LS_COLOR( 158//usage: IF_FEATURE_LS_COLOR(
@@ -263,7 +268,7 @@ static const char ls_options[] ALIGN1 =
263 IF_SELINUX("KZ") /* 2, 26 */ 268 IF_SELINUX("KZ") /* 2, 26 */
264 IF_FEATURE_LS_FOLLOWLINKS("LH") /* 2, 28 */ 269 IF_FEATURE_LS_FOLLOWLINKS("LH") /* 2, 28 */
265 IF_FEATURE_HUMAN_READABLE("h") /* 1, 29 */ 270 IF_FEATURE_HUMAN_READABLE("h") /* 1, 29 */
266 IF_FEATURE_AUTOWIDTH("T:w:") /* 2, 31 */ 271 IF_FEATURE_LS_WIDTH("T:w:") /* 2, 31 */
267 /* with --color, we use all 32 bits */; 272 /* with --color, we use all 32 bits */;
268enum { 273enum {
269 //OPT_C = (1 << 0), 274 //OPT_C = (1 << 0),
@@ -298,7 +303,7 @@ enum {
298 OPTBIT_h = OPTBIT_L + 2 * ENABLE_FEATURE_LS_FOLLOWLINKS, 303 OPTBIT_h = OPTBIT_L + 2 * ENABLE_FEATURE_LS_FOLLOWLINKS,
299 OPTBIT_T = OPTBIT_h + 1 * ENABLE_FEATURE_HUMAN_READABLE, 304 OPTBIT_T = OPTBIT_h + 1 * ENABLE_FEATURE_HUMAN_READABLE,
300 OPTBIT_w, /* 30 */ 305 OPTBIT_w, /* 30 */
301 OPTBIT_color = OPTBIT_T + 2 * ENABLE_FEATURE_AUTOWIDTH, 306 OPTBIT_color = OPTBIT_T + 2 * ENABLE_FEATURE_LS_WIDTH,
302 307
303 OPT_c = (1 << OPTBIT_c) * ENABLE_FEATURE_LS_TIMESTAMPS, 308 OPT_c = (1 << OPTBIT_c) * ENABLE_FEATURE_LS_TIMESTAMPS,
304 OPT_e = (1 << OPTBIT_e) * ENABLE_FEATURE_LS_TIMESTAMPS, 309 OPT_e = (1 << OPTBIT_e) * ENABLE_FEATURE_LS_TIMESTAMPS,
@@ -316,8 +321,8 @@ enum {
316 OPT_L = (1 << OPTBIT_L) * ENABLE_FEATURE_LS_FOLLOWLINKS, 321 OPT_L = (1 << OPTBIT_L) * ENABLE_FEATURE_LS_FOLLOWLINKS,
317 OPT_H = (1 << OPTBIT_H) * ENABLE_FEATURE_LS_FOLLOWLINKS, 322 OPT_H = (1 << OPTBIT_H) * ENABLE_FEATURE_LS_FOLLOWLINKS,
318 OPT_h = (1 << OPTBIT_h) * ENABLE_FEATURE_HUMAN_READABLE, 323 OPT_h = (1 << OPTBIT_h) * ENABLE_FEATURE_HUMAN_READABLE,
319 OPT_T = (1 << OPTBIT_T) * ENABLE_FEATURE_AUTOWIDTH, 324 OPT_T = (1 << OPTBIT_T) * ENABLE_FEATURE_LS_WIDTH,
320 OPT_w = (1 << OPTBIT_w) * ENABLE_FEATURE_AUTOWIDTH, 325 OPT_w = (1 << OPTBIT_w) * ENABLE_FEATURE_LS_WIDTH,
321 OPT_color = (1 << OPTBIT_color) * ENABLE_FEATURE_LS_COLOR, 326 OPT_color = (1 << OPTBIT_color) * ENABLE_FEATURE_LS_COLOR,
322}; 327};
323 328
@@ -417,7 +422,7 @@ struct globals {
417#endif 422#endif
418 smallint exit_code; 423 smallint exit_code;
419 unsigned all_fmt; 424 unsigned all_fmt;
420#if ENABLE_FEATURE_AUTOWIDTH 425#if ENABLE_FEATURE_LS_WIDTH
421 unsigned terminal_width; 426 unsigned terminal_width;
422# define G_terminal_width (G.terminal_width) 427# define G_terminal_width (G.terminal_width)
423#else 428#else
@@ -433,7 +438,7 @@ struct globals {
433 setup_common_bufsiz(); \ 438 setup_common_bufsiz(); \
434 /* we have to zero it out because of NOEXEC */ \ 439 /* we have to zero it out because of NOEXEC */ \
435 memset(&G, 0, sizeof(G)); \ 440 memset(&G, 0, sizeof(G)); \
436 IF_FEATURE_AUTOWIDTH(G_terminal_width = TERMINAL_WIDTH;) \ 441 IF_FEATURE_LS_WIDTH(G_terminal_width = TERMINAL_WIDTH;) \
437 IF_FEATURE_LS_TIMESTAMPS(time(&G.current_time_t);) \ 442 IF_FEATURE_LS_TIMESTAMPS(time(&G.current_time_t);) \
438} while (0) 443} while (0)
439 444
@@ -1167,7 +1172,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
1167 if (ENABLE_FEATURE_LS_SORTFILES) 1172 if (ENABLE_FEATURE_LS_SORTFILES)
1168 G.all_fmt = SORT_NAME; 1173 G.all_fmt = SORT_NAME;
1169 1174
1170#if ENABLE_FEATURE_AUTOWIDTH 1175#if ENABLE_FEATURE_LS_WIDTH
1171 /* obtain the terminal width */ 1176 /* obtain the terminal width */
1172 G_terminal_width = get_terminal_width(STDIN_FILENO); 1177 G_terminal_width = get_terminal_width(STDIN_FILENO);
1173 /* go one less... */ 1178 /* go one less... */
@@ -1190,9 +1195,9 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
1190 ":x-1:1-x" /* bylines/oneline (not in SuS, but in GNU coreutils 8.4) */ 1195 ":x-1:1-x" /* bylines/oneline (not in SuS, but in GNU coreutils 8.4) */
1191 IF_FEATURE_LS_TIMESTAMPS(":c-u:u-c") /* mtime/atime */ 1196 IF_FEATURE_LS_TIMESTAMPS(":c-u:u-c") /* mtime/atime */
1192 /* -w NUM: */ 1197 /* -w NUM: */
1193 IF_FEATURE_AUTOWIDTH(":w+"); 1198 IF_FEATURE_LS_WIDTH(":w+");
1194 opt = getopt32(argv, ls_options 1199 opt = getopt32(argv, ls_options
1195 IF_FEATURE_AUTOWIDTH(, NULL, &G_terminal_width) 1200 IF_FEATURE_LS_WIDTH(, NULL, &G_terminal_width)
1196 IF_FEATURE_LS_COLOR(, &color_opt) 1201 IF_FEATURE_LS_COLOR(, &color_opt)
1197 ); 1202 );
1198 for (i = 0; opt_flags[i] != (1U << 31); i++) { 1203 for (i = 0; opt_flags[i] != (1U << 31); i++) {
diff --git a/networking/telnet.c b/networking/telnet.c
index f520fe1dd..a70f74762 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -45,6 +45,11 @@
45//config: remote host you are connecting to. This is useful when you need to 45//config: remote host you are connecting to. This is useful when you need to
46//config: log into a machine without telling the username (autologin). This 46//config: log into a machine without telling the username (autologin). This
47//config: option enables `-a' and `-l USER' arguments. 47//config: option enables `-a' and `-l USER' arguments.
48//config:
49//config:config FEATURE_TELNET_WIDTH
50//config: bool "Enable window size autodetection"
51//config: default y
52//config: depends on TELNET
48 53
49//applet:IF_TELNET(APPLET(telnet, BB_DIR_USR_BIN, BB_SUID_DROP)) 54//applet:IF_TELNET(APPLET(telnet, BB_DIR_USR_BIN, BB_SUID_DROP))
50 55
@@ -128,7 +133,7 @@ struct globals {
128#if ENABLE_FEATURE_TELNET_AUTOLOGIN 133#if ENABLE_FEATURE_TELNET_AUTOLOGIN
129 const char *autologin; 134 const char *autologin;
130#endif 135#endif
131#if ENABLE_FEATURE_AUTOWIDTH 136#if ENABLE_FEATURE_TELNET_WIDTH
132 unsigned win_width, win_height; 137 unsigned win_width, win_height;
133#endif 138#endif
134 /* same buffer used both for network and console read/write */ 139 /* same buffer used both for network and console read/write */
@@ -401,7 +406,7 @@ static void put_iac_subopt_autologin(void)
401} 406}
402#endif 407#endif
403 408
404#if ENABLE_FEATURE_AUTOWIDTH 409#if ENABLE_FEATURE_TELNET_WIDTH
405static void put_iac_naws(byte c, int x, int y) 410static void put_iac_naws(byte c, int x, int y)
406{ 411{
407 if (G.iaclen + 9 > IACBUFSIZE) 412 if (G.iaclen + 9 > IACBUFSIZE)
@@ -538,7 +543,7 @@ static void to_new_environ(void)
538} 543}
539#endif 544#endif
540 545
541#if ENABLE_FEATURE_AUTOWIDTH 546#if ENABLE_FEATURE_TELNET_WIDTH
542static void to_naws(void) 547static void to_naws(void)
543{ 548{
544 /* Tell server we will do NAWS */ 549 /* Tell server we will do NAWS */
@@ -561,7 +566,7 @@ static void telopt(byte c)
561 case TELOPT_NEW_ENVIRON: 566 case TELOPT_NEW_ENVIRON:
562 to_new_environ(); break; 567 to_new_environ(); break;
563#endif 568#endif
564#if ENABLE_FEATURE_AUTOWIDTH 569#if ENABLE_FEATURE_TELNET_WIDTH
565 case TELOPT_NAWS: 570 case TELOPT_NAWS:
566 to_naws(); 571 to_naws();
567 put_iac_naws(c, G.win_width, G.win_height); 572 put_iac_naws(c, G.win_width, G.win_height);
@@ -623,7 +628,7 @@ int telnet_main(int argc UNUSED_PARAM, char **argv)
623 628
624 INIT_G(); 629 INIT_G();
625 630
626#if ENABLE_FEATURE_AUTOWIDTH 631#if ENABLE_FEATURE_TELNET_WIDTH
627 get_terminal_width_height(0, &G.win_width, &G.win_height); 632 get_terminal_width_height(0, &G.win_width, &G.win_height);
628#endif 633#endif
629 634