aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@frippery.org>2015-07-19 11:12:29 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2015-07-19 22:34:13 +0200
commit51aa861843002e92b605be840460e7141d4d86a2 (patch)
treebf374b3a4748e8e597990f5dd619522f5778c9a7 /miscutils
parent072fc60f29ee3a4ff38f095a9ef149b2e820c8c0 (diff)
downloadbusybox-w32-51aa861843002e92b605be840460e7141d4d86a2.tar.gz
busybox-w32-51aa861843002e92b605be840460e7141d4d86a2.tar.bz2
busybox-w32-51aa861843002e92b605be840460e7141d4d86a2.zip
less: document -S flag and make it independently configurable
The -S flag, to cause long lines to be truncated, was enabled by FEATURE_LESS_DASHCMD. This is non-obvious and -S is useful even if the '-' command isn't enabled. function old new delta .rodata 156045 156077 +32 packed_usage 30223 30244 +21 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 53/0) Total: 53 bytes Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/less.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index d5a68d1e1..c1755655a 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -48,6 +48,14 @@
48//config: help 48//config: help
49//config: The -M/-m flag enables a more sophisticated status line. 49//config: The -M/-m flag enables a more sophisticated status line.
50//config: 50//config:
51//config:config FEATURE_LESS_TRUNCATE
52//config: bool "Enable -S"
53//config: default y
54//config: depends on LESS
55//config: help
56//config: The -S flag causes long lines to be truncated rather than
57//config: wrapped.
58//config:
51//config:config FEATURE_LESS_MARKS 59//config:config FEATURE_LESS_MARKS
52//config: bool "Enable marks" 60//config: bool "Enable marks"
53//config: default y 61//config: default y
@@ -98,7 +106,8 @@
98//config: Enables "-N" command. 106//config: Enables "-N" command.
99 107
100//usage:#define less_trivial_usage 108//usage:#define less_trivial_usage
101//usage: "[-E" IF_FEATURE_LESS_REGEXP("I")IF_FEATURE_LESS_FLAGS("Mm") "Nh~] [FILE]..." 109//usage: "[-E" IF_FEATURE_LESS_REGEXP("I")IF_FEATURE_LESS_FLAGS("Mm")
110//usage: "N" IF_FEATURE_LESS_TRUNCATE("S") "h~] [FILE]..."
102//usage:#define less_full_usage "\n\n" 111//usage:#define less_full_usage "\n\n"
103//usage: "View FILE (or stdin) one screenful at a time\n" 112//usage: "View FILE (or stdin) one screenful at a time\n"
104//usage: "\n -E Quit once the end of a file is reached" 113//usage: "\n -E Quit once the end of a file is reached"
@@ -110,6 +119,9 @@
110//usage: "\n and percentage through the file" 119//usage: "\n and percentage through the file"
111//usage: ) 120//usage: )
112//usage: "\n -N Prefix line number to each line" 121//usage: "\n -N Prefix line number to each line"
122//usage: IF_FEATURE_LESS_TRUNCATE(
123//usage: "\n -S Truncate long lines"
124//usage: )
113//usage: "\n -~ Suppress ~s displayed past EOF" 125//usage: "\n -~ Suppress ~s displayed past EOF"
114 126
115#include <sched.h> /* sched_yield() */ 127#include <sched.h> /* sched_yield() */
@@ -144,7 +156,7 @@ enum {
144 FLAG_N = 1 << 3, 156 FLAG_N = 1 << 3,
145 FLAG_TILDE = 1 << 4, 157 FLAG_TILDE = 1 << 4,
146 FLAG_I = 1 << 5, 158 FLAG_I = 1 << 5,
147 FLAG_S = (1 << 6) * ENABLE_FEATURE_LESS_DASHCMD, 159 FLAG_S = (1 << 6) * ENABLE_FEATURE_LESS_TRUNCATE,
148/* hijack command line options variable for internal state vars */ 160/* hijack command line options variable for internal state vars */
149 LESS_STATE_MATCH_BACKWARDS = 1 << 15, 161 LESS_STATE_MATCH_BACKWARDS = 1 << 15,
150}; 162};
@@ -820,7 +832,7 @@ static void buffer_print(void)
820static void buffer_fill_and_print(void) 832static void buffer_fill_and_print(void)
821{ 833{
822 unsigned i; 834 unsigned i;
823#if ENABLE_FEATURE_LESS_DASHCMD 835#if ENABLE_FEATURE_LESS_TRUNCATE
824 int fpos = cur_fline; 836 int fpos = cur_fline;
825 837
826 if (option_mask32 & FLAG_S) { 838 if (option_mask32 & FLAG_S) {
@@ -1330,10 +1342,12 @@ static void flag_change(void)
1330 case '~': 1342 case '~':
1331 option_mask32 ^= FLAG_TILDE; 1343 option_mask32 ^= FLAG_TILDE;
1332 break; 1344 break;
1345#if ENABLE_FEATURE_LESS_TRUNCATE
1333 case 'S': 1346 case 'S':
1334 option_mask32 ^= FLAG_S; 1347 option_mask32 ^= FLAG_S;
1335 buffer_fill_and_print(); 1348 buffer_fill_and_print();
1336 break; 1349 break;
1350#endif
1337#if ENABLE_FEATURE_LESS_LINENUMS 1351#if ENABLE_FEATURE_LESS_LINENUMS
1338 case 'N': 1352 case 'N':
1339 option_mask32 ^= FLAG_N; 1353 option_mask32 ^= FLAG_N;
@@ -1638,7 +1652,7 @@ int less_main(int argc, char **argv)
1638 * -s: condense many empty lines to one 1652 * -s: condense many empty lines to one
1639 * (used by some setups for manpage display) 1653 * (used by some setups for manpage display)
1640 */ 1654 */
1641 getopt32(argv, "EMmN~I" IF_FEATURE_LESS_DASHCMD("S") /*ignored:*/"s"); 1655 getopt32(argv, "EMmN~I" IF_FEATURE_LESS_TRUNCATE("S") /*ignored:*/"s");
1642 argc -= optind; 1656 argc -= optind;
1643 argv += optind; 1657 argv += optind;
1644 num_files = argc; 1658 num_files = argc;