summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorDylan Cali <calid1984@gmail.com>2014-09-05 04:42:02 -0500
committerPádraig Brady <P@draigBrady.com>2015-06-19 19:59:21 +0100
commit71063bc858cd927e3622b511297e66b3e13f7453 (patch)
treef7574dc51bb55b27881a2d063fb37c76198a4be4 /doc
parent5863426dcfec2336cf0e1a28255e9080889fcb4c (diff)
downloadcoreutils-71063bc858cd927e3622b511297e66b3e13f7453.tar.xz
numfmt: implement support for field ranges
* src/numfmt.c: Replace field handling code with logic that understands field range specifiers. Instead of processing a single field and printing line prefix/suffix around it, process each field in the line checking whether it has been included for conversion. If so convert and print, otherwise just print the unaltered field. (extract_fields): Removed. (skip_fields): Removed. (process_line): Gutted and heavily reworked. (process_suffixed_number): FIELD is now passed as an arg instead of using a global. (parse_field_arg): New function that parses field range specifiers. (next_field): New function that returns pointers to the next field in a line. (process_field): New function that wraps the field conversion logic (include_field): New function that checks whether a field should be converted (compare_field): New function used for field value comparisons in a gl_list. (free_field): New function used for freeing field values in a gl_list. Global variable FIELD removed. New global variable all_fields indicates whether all fields should be processed. New global variable all_fields_after stores the first field of a N- style range. New global variable all_fields_before stores the last field of a -M style range. New global variable field_list stores explicitly specified fields to process (N N,M or N-M style specifiers). (usage): Document newly supported field range specifiers. * bootstrap.conf: Include xlist and linked-list modules. numfmt now uses the gl_linked_list implementation to store the field ranges. * tests/misc/numfmt.pl: Add tests for 'cut style' field ranges. Adjust existing tests as partial output can occur before an error Remove test for the 'invalid' field -5.. this is now a valid range. * gnulib: update to avoid compiler warnings in linked-list. * NEWS: Mention the new feature.
Diffstat (limited to 'doc')
-rw-r--r--doc/coreutils.texi14
1 files changed, 12 insertions, 2 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 08316c928..9197cb426 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -16892,9 +16892,19 @@ Print (to standard error) warning messages about possible erroneous usage.
Use the character @var{d} as input field separator (default: whitespace).
@emph{Note}: Using non-default delimiter turns off automatic padding.
-@item --field=@var{n}
+@item --field=@var{fields}
@opindex --field
-Convert the number in input field @var{n} (default: 1).
+Convert the number in input field @var{fields} (default: 1).
+@var{fields} supports @command{cut} style field ranges:
+
+@example
+N N'th field, counted from 1
+N- from N'th field, to end of line
+N-M from N'th to M'th field (inclusive)
+-M from first to M'th field (inclusive)
+- all fields
+@end example
+
@item --format=@var{format}
@opindex --format