[PATCH] support for -w in seq
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Mon Nov 10 13:22:11 UTC 2008
On Mon, Nov 10, 2008 at 01:55:22PM +0100, Bernhard Reutner-Fischer wrote:
>On Mon, Nov 10, 2008 at 12:02:12PM +0100, Natanael Copa wrote:
>>attatched is a patch that adds support for the -w option to seq.
>
>Didn't work for 10 -1 8 (missing ^+ in getopt32)
>and forgot to update the usage.
>What about separator support? Would need to suppress printing the sep if
>it was the last occurance..
something like the attached. Quite bloated, though..
function old new delta
seq_main 235 341 +106
packed_usage 13671 13708 +37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 143/0) Total: 143 bytes
Denys, please install and/or adjust.
Cheers,
>># ./busybox seq -w 001 010
>>001
>>002
>>003
>>004
>>005
>>006
>>007
>>008
>>009
>>010
>>
>># make bloatcheck
>>function old new delta
>>seq_main 268 320 +52
>>.rodata 169558 169564 +6
>>------------------------------------------------------------------------------
>>(add/remove: 0/0 grow/shrink: 2/0 up/down: 58/0) Total: 58
>>bytes
>> text data bss dec hex filename
>> 942990 9145 5288 957423 e9bef busybox_old
>> 943048 9145 5288 957481 e9c29 busybox_unstripped
>>
>>-nc
>
>>Index: coreutils/seq.c
>>===================================================================
>>--- coreutils/seq.c (revision 23942)
>>+++ coreutils/seq.c (working copy)
>>@@ -16,6 +16,10 @@
>> int seq_main(int argc, char **argv)
>> {
>> double last, increment, i;
>>+ int width = getopt32(argv, "w");
>>+
>>+ argc -= optind;
>>+ argv += optind;
>>
>> i = increment = 1;
>> switch (argc) {
>>@@ -29,10 +33,12 @@
>> default:
>> bb_show_usage();
>> }
>>+ if (width)
>>+ width = strlen(argv[argc-1]);
>>
>> /* You should note that this is pos-5.0.91 semantics, -- FK. */
>> while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) {
>>- printf("%g\n", i);
>>+ printf("%0*g\n", width, i);
>> i += increment;
>> }
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: seq-w.02.patch
Type: text/x-diff
Size: 1851 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20081110/2640b3e4/attachment.bin
More information about the busybox
mailing list