Re: [9fans] seq with hex, octal formats

2010-02-27 Thread erik quanstrom
On Sat Feb 27 21:08:17 EST 2010, lyn...@orthanc.ca wrote: > > using awk is still faster > > For the curious and lazy ... why is that? it is curious! it appears that the ape strtod is much faster, though it isn't quite correct: both of these are in /sys/src/libc/port/strtod.c % Time C

Re: [9fans] seq with hex, octal formats

2010-02-27 Thread Lyndon Nerenberg (VE6BBM/VE7TFX)
> using awk is still faster For the curious and lazy ... why is that?

Re: [9fans] seq with hex, octal formats

2010-02-27 Thread erik quanstrom
very nice! one problem, ifmt can crash with the argument -f %g. fomatting %g will mean that !running to be true when calling ifmt, thus ifmt will try to va_arg a double cast to vlong when formatting an integer: /sys/src/libc/fmt/fltfmt.c:136: sprint(s1+NSIGNIF, "e%d", e-NSIGNIF+1

Re: [9fans] seq with hex, octal formats

2010-02-27 Thread Russ Cox
diff -r 3024d1ef1140 src/cmd/seq.c --- a/src/cmd/seq.c Wed Sep 30 11:01:45 2009 -0700 +++ b/src/cmd/seq.c Sat Feb 27 16:11:56 2010 -0800 @@ -47,6 +47,39 @@ format = fmt; } +extern int __ifmt(Fmt*); // _ifmt on Plan 9 + +static int +doifmt(Fmt *f, ...) +{ + int rv; +

[9fans] seq with hex, octal formats

2010-02-27 Thread erik quanstrom
i've attached a little program that extends seq to print sequences in hex or octal. for example, ; seq.rc -f %.4x 0x3b1 0x3b2 03b1 03b2 i did it in rc (really awk) because it was too tedious to get the details right in c. as such, formats are as in printf(2) not as in p