summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-05-12 08:55:13 +0000
committerJim Meyering <jim@meyering.net>2000-05-12 08:55:13 +0000
commit1224b48d7fed96c2beb1b294b294ec716d33a6aa (patch)
tree867ad8056fdf6dab9d80bb390aaa1387382bfad3 /src
parent3b8a52ccbe59bf6128401eb2a1ad0f68c19151f8 (diff)
downloadcoreutils-1224b48d7fed96c2beb1b294b294ec716d33a6aa.tar.xz
New option: --first-only
(anonymous enum) [CONVERT_FIRST_ONLY_OPTION]: Define. (long_options): Add `first-only'. (main): Handle new option.
Diffstat (limited to 'src')
-rw-r--r--src/unexpand.c18
1 files changed, 18 insertions, 0 deletions
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);