From 4c85c757e55c1b75635672624632e3e6c92c5dd1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Sun, 2 Apr 2017 16:52:34 -0700 Subject: [PATCH] doc: refactor and update expand and unexpand --help * src/expand-common.c (emit_tab_list_info): A new function to output the extended info on --tab=LIST, including the new '+' and '/' prefixes. * src/expand-common.h: Declare the above. * src/expand.c (usage:): Call emit_tab_list_info and match alignment with that used in unexpand --help. * src/unexpand.c (usage): Likewise. --- src/expand-common.c | 17 +++++++++++++++++ src/expand-common.h | 4 ++++ src/expand.c | 8 +++----- src/unexpand.c | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/expand-common.c b/src/expand-common.c index 05e5bec2d8..8c83fb3652 100644 --- a/src/expand-common.c +++ b/src/expand-common.c @@ -382,3 +382,20 @@ cleanup_file_list_stdin (void) if (have_read_stdin && fclose (stdin) != 0) die (EXIT_FAILURE, errno, "-"); } + + +extern void +emit_tab_list_info (void) +{ + /* suppress syntax check for emit_mandatory_arg_note() */ + fputs (_("\ + -t, --tabs=LIST use comma separated list of tab positions\n\ +"), stdout); + fputs (_("\ + The last specified position can be prefixed with '/'\n\ + to specify a tab size to use after the last\n\ + explicitly specified tab stop. Also a prefix of '+'\n\ + can be used to align remaining tab stops relative to\n\ + the last specified tab stop instead of the first column\n\ +"), stdout); +} diff --git a/src/expand-common.h b/src/expand-common.h index 5eec99d6ba..8cc6ebe198 100644 --- a/src/expand-common.h +++ b/src/expand-common.h @@ -70,3 +70,7 @@ next_file (FILE *fp); /* */ extern void cleanup_file_list_stdin (void); + + +extern void +emit_tab_list_info (void); diff --git a/src/expand.c b/src/expand.c index 2b7781ca51..1e783169a2 100644 --- a/src/expand.c +++ b/src/expand.c @@ -78,12 +78,10 @@ Convert tabs in each FILE to spaces, writing to standard output.\n\ emit_mandatory_arg_note (); fputs (_("\ - -i, --initial do not convert tabs after non blanks\n\ - -t, --tabs=NUMBER have tabs NUMBER characters apart, not 8\n\ -"), stdout); - fputs (_("\ - -t, --tabs=LIST use comma separated list of explicit tab positions\n\ + -i, --initial do not convert tabs after non blanks\n\ + -t, --tabs=N have tabs N characters apart, not 8\n\ "), stdout); + emit_tab_list_info (); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_ancillary_info (PROGRAM_NAME); diff --git a/src/unexpand.c b/src/unexpand.c index fd334ddc80..60c9422ef4 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -90,8 +90,8 @@ Convert blanks in each FILE to tabs, writing to standard output.\n\ -a, --all convert all blanks, instead of just initial blanks\n\ --first-only convert only leading sequences of blanks (overrides -a)\n\ -t, --tabs=N have tabs N characters apart instead of 8 (enables -a)\n\ - -t, --tabs=LIST use comma separated LIST of tab positions (enables -a)\n\ "), stdout); + emit_tab_list_info (); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_ancillary_info (PROGRAM_NAME); -- 2.47.2