[PATCH] less: document -S flag and make it independently configurable
Denys Vlasenko
vda.linux at googlemail.com
Sun Jul 19 20:33:41 UTC 2015
Applied, thanks!
On Sun, Jul 19, 2015 at 12:12 PM, Ron Yorston <rmy at frippery.org> wrote:
> 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 at pobox.com>
> ---
> miscutils/less.c | 22 ++++++++++++++++++----
> 1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/miscutils/less.c b/miscutils/less.c
> index 87cff40..7c46ba5 100644
> --- a/miscutils/less.c
> +++ b/miscutils/less.c
> @@ -48,6 +48,14 @@
> //config: help
> //config: The -M/-m flag enables a more sophisticated status line.
> //config:
> +//config:config FEATURE_LESS_TRUNCATE
> +//config: bool "Enable -S"
> +//config: default y
> +//config: depends on LESS
> +//config: help
> +//config: The -S flag causes long lines to be truncated rather than
> +//config: wrapped.
> +//config:
> //config:config FEATURE_LESS_MARKS
> //config: bool "Enable marks"
> //config: default y
> @@ -98,7 +106,8 @@
> //config: Enables "-N" command.
>
> //usage:#define less_trivial_usage
> -//usage: "[-E" IF_FEATURE_LESS_REGEXP("I")IF_FEATURE_LESS_FLAGS("Mm") "Nh~] [FILE]..."
> +//usage: "[-E" IF_FEATURE_LESS_REGEXP("I")IF_FEATURE_LESS_FLAGS("Mm")
> +//usage: "N" IF_FEATURE_LESS_TRUNCATE("S") "h~] [FILE]..."
> //usage:#define less_full_usage "\n\n"
> //usage: "View FILE (or stdin) one screenful at a time\n"
> //usage: "\n -E Quit once the end of a file is reached"
> @@ -110,6 +119,9 @@
> //usage: "\n and percentage through the file"
> //usage: )
> //usage: "\n -N Prefix line number to each line"
> +//usage: IF_FEATURE_LESS_TRUNCATE(
> +//usage: "\n -S Truncate long lines"
> +//usage: )
> //usage: "\n -~ Suppress ~s displayed past EOF"
>
> #include <sched.h> /* sched_yield() */
> @@ -144,7 +156,7 @@ enum {
> FLAG_N = 1 << 3,
> FLAG_TILDE = 1 << 4,
> FLAG_I = 1 << 5,
> - FLAG_S = (1 << 6) * ENABLE_FEATURE_LESS_DASHCMD,
> + FLAG_S = (1 << 6) * ENABLE_FEATURE_LESS_TRUNCATE,
> /* hijack command line options variable for internal state vars */
> LESS_STATE_MATCH_BACKWARDS = 1 << 15,
> };
> @@ -807,7 +819,7 @@ static void buffer_print(void)
> static void buffer_fill_and_print(void)
> {
> unsigned i;
> -#if ENABLE_FEATURE_LESS_DASHCMD
> +#if ENABLE_FEATURE_LESS_TRUNCATE
> int fpos = cur_fline;
>
> if (option_mask32 & FLAG_S) {
> @@ -1317,10 +1329,12 @@ static void flag_change(void)
> case '~':
> option_mask32 ^= FLAG_TILDE;
> break;
> +#if ENABLE_FEATURE_LESS_TRUNCATE
> case 'S':
> option_mask32 ^= FLAG_S;
> buffer_fill_and_print();
> break;
> +#endif
> #if ENABLE_FEATURE_LESS_LINENUMS
> case 'N':
> option_mask32 ^= FLAG_N;
> @@ -1625,7 +1639,7 @@ int less_main(int argc, char **argv)
> * -s: condense many empty lines to one
> * (used by some setups for manpage display)
> */
> - getopt32(argv, "EMmN~I" IF_FEATURE_LESS_DASHCMD("S") /*ignored:*/"s");
> + getopt32(argv, "EMmN~I" IF_FEATURE_LESS_TRUNCATE("S") /*ignored:*/"s");
> argc -= optind;
> argv += optind;
> num_files = argc;
> --
> 2.4.3
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list