From: Russ Cox <rsc@swtch.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] seq with hex, octal formats
Date: Sat, 27 Feb 2010 16:12:53 -0800 [thread overview]
Message-ID: <dd6fe68a1002271612w334e8286h2247e77a3cf5a2d5@mail.gmail.com> (raw)
In-Reply-To: <2dfd9898fe7656a885285032d9727684@ladd.quanstro.net>
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;
+ va_list argsav;
+
+ f->flags |= FmtVLong;
+ va_copy(argsav, f->args);
+ va_end(f->args);
+ va_start(f->args, f);
+ rv = __ifmt(f);
+ va_end(f->args);
+ va_copy(f->args, argsav);
+ va_end(argsav);
+ return rv;
+}
+
+static int
+ifmt(Fmt *f)
+{
+ int rv;
+ static int running;
+
+ if(running)
+ return __ifmt(f);
+ running = 1;
+ rv = doifmt(f, (vlong)va_arg(f->args, double));
+ running = 0;
+ return rv;
+}
+
void
main(int argc, char *argv[]){
int j, n;
@@ -79,7 +112,11 @@
fprint(2, "seq: zero increment\n");
exits("zero increment");
}
- if(!format)
+ if(format){
+ fmtinstall('d', ifmt);
+ fmtinstall('o', ifmt);
+ fmtinstall('x', ifmt);
+ }else
buildfmt();
if(incr > 0){
for(val = min; val <= max; val += incr){
next prev parent reply other threads:[~2010-02-28 0:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-27 19:01 erik quanstrom
2010-02-28 0:12 ` Russ Cox [this message]
2010-02-28 1:59 ` erik quanstrom
2010-02-28 2:07 ` Lyndon Nerenberg (VE6BBM/VE7TFX)
2010-02-28 2:15 ` erik quanstrom
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd6fe68a1002271612w334e8286h2247e77a3cf5a2d5@mail.gmail.com \
--to=rsc@swtch.com \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).