coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: numfmt: minor improvements to --field parsing


From: Assaf Gordon
Subject: Re: numfmt: minor improvements to --field parsing
Date: Wed, 15 Jul 2015 19:58:16 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

Hello Pádraig,

On 07/12/2015 02:33 PM, Pádraig Brady wrote:
<...>
Hmm. Shouldn't we treat the above like field 1 and all fields up to 2 inclusive?
Similarly shouldn't we allow ranges like:

$ echo 1 2 3 4 5 | numfmt --field -2,4- --to-unit=1000 --round=down
0 0 3 0 0

$ echo 1 2 3 4 5 | numfmt --field -2,-4 --to-unit=1000 --round=down
0 0 0 0 5

Attached is a reworked patch. In it, I've copied the 'set_fields' function from 
cut almost verbatim.
now numfmt accepts the same variations as 'cut --fields=LIST' (including the 
examples you mentioned above),
with the addition that '--field=-' means 'all fields'.

To illustrate, attached are excerpts of 'set_fields' from cut.c and numfmt.c, a 
diff between them will show the minor changes.

comments welcomed,
 - assaf

Attachment: numfmt-field-2015-07-15.patch
Description: Text Data

Attachment: cut-set-fields.c
Description: Text Data

Attachment: numfmt-set-fields.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]