From 1224b48d7fed96c2beb1b294b294ec716d33a6aa Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 12 May 2000 08:55:13 +0000 Subject: [PATCH] New option: --first-only (anonymous enum) [CONVERT_FIRST_ONLY_OPTION]: Define. (long_options): Add `first-only'. (main): Handle new option. --- src/unexpand.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/unexpand.c b/src/unexpand.c index 14eecae52..02420fff8 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -96,10 +96,18 @@ static int have_read_stdin; /* Status to return to the system. */ static int exit_status; +/* For long options that have no equivalent short option, use a + non-character as a pseudo short option, starting with CHAR_MAX + 1. */ +enum +{ + CONVERT_FIRST_ONLY_OPTION = CHAR_MAX + 1 +}; + static struct option const longopts[] = { {"tabs", required_argument, NULL, 't'}, {"all", no_argument, NULL, 'a'}, + {"first-only", no_argument, NULL, CONVERT_FIRST_ONLY_OPTION}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} @@ -390,6 +398,10 @@ main (int argc, char **argv) int tabval = -1; /* Value of tabstop being read, or -1. */ int c; /* Option character. */ + /* If nonzero, cancel the effect of any -a (explicit or implicit in -t), + so that only leading white space will be considered. */ + int convert_first_only = 0; + program_name = argv[0]; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -417,6 +429,9 @@ main (int argc, char **argv) convert_entire_line = 1; parse_tabstops (optarg); break; + case CONVERT_FIRST_ONLY_OPTION: + convert_first_only = 1; + break; case ',': add_tabstop (tabval); tabval = -1; @@ -431,6 +446,9 @@ main (int argc, char **argv) } } + if (convert_first_only) + convert_entire_line = 0; + add_tabstop (tabval); validate_tabstops (tab_list, first_free_tab);