# HG changeset patch # User Rob Landley # Date 1354046157 21600 # Node ID 54294a48a09bdecf9b800f2bd3c8e23e320ace3b # Parent 8c10cf7bace0b77f4b9bbbee4ce21c48623db62a First round of expand cleanups. diff -r 8c10cf7bace0 -r 54294a48a09b toys/posix/expand.c --- a/toys/posix/expand.c Fri Nov 23 09:24:53 2012 +0100 +++ b/toys/posix/expand.c Tue Nov 27 13:55:57 2012 -0600 @@ -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 @@ 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); }