From 11ca9293c62041d5d0a4c44de21ba786524bfac3 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 27 Nov 2012 13:55:57 -0600 Subject: First round of expand cleanups. --- toys/posix/expand.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'toys/posix') diff --git a/toys/posix/expand.c b/toys/posix/expand.c index bbe6fdf1..a322926a 100644 --- a/toys/posix/expand.c +++ b/toys/posix/expand.c @@ -2,36 +2,23 @@ * * Copyright 2012 Jonathan Clairembault * - * See http://http://pubs.opengroup.org/onlinepubs/9699919799/nframe.html + * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/expand.html USE_EXPAND(NEWTOY(expand, "t:", TOYFLAG_USR|TOYFLAG_BIN)) config EXPAND bool "expand" - default n + default y help usage: expand [-t tablist] [file...] - Command expand. Expands tabs to space according to tabstops. + Expand tabs to spaces according to tabstops. - -t tablist - Specify the tab stops. The argument tablist consists of either a single - strictly positive decimal integer or a list of tabstops. If a single number - is given, tabs are set that number of column positions apart instead of the - default 8. + -t tablist - If a list of tabstops is given, the list is made of two or more strictly - positive decimal integers, separated by or characters, in - strictly ascending order. The characters are set at those specific - column positions. - - In the event of expand having to process a at a position beyond the - last of those specified in a multiple tab-stop list, the is replaced - by a single in the output. - - Any characters shall be copied to the output and cause the - column position count for tab stop calculations to be decremented; the - column position count shall not be decremented below zero. + Specify tab stops, either a single number instead of the default 8, + or a list of increasing numbers (comma or space separated, after which + each additional tab becomes one space). */ #define FOR_expand @@ -135,8 +122,7 @@ static void expand_file(int fd, char *name) void expand_main(void) { build_tablist((toys.optflags & FLAG_t) ? TT.t_flags : "8"); - /* expand every file */ + loopfiles(toys.optargs, expand_file); - /* free tablist */ - llist_traverse(TT.tablist.next, free); + if (CFG_TOYBOX_FREE) llist_traverse(TT.tablist.next, free); } -- cgit v1.2.3