9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] seq with hex, octal formats
Date: Sat, 27 Feb 2010 20:59:39 -0500	[thread overview]
Message-ID: <d69aeb1d4bdbff6163069c3ce56888bb@ladd.quanstro.net> (raw)
In-Reply-To: <dd6fe68a1002271612w334e8286h2247e77a3cf5a2d5@mail.gmail.com>

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);
/sys/src/libc/fmt/fltfmt.c:142: 			sprint(s1+NSIGNIF, "e%d", e-NSIGNIF+1);
/sys/src/libc/fmt/fltfmt.c:155: 		sprint(s1+NSIGNIF, "e%d", e-NSIGNIF+1);

(actually, on testing, this version spins rather than crashes
on plan 9:
; ps -a | grep 1308769
quanstro    1308769    1:30   0:00       28K Running  8.seqrsc -f %g 1 5
)

using awk is still faster, and more
fundamentally, avoids crashing on bogus
formats like %g%g.

(also, -w doesn't work with either version
with a %x format because 'e' is a valid hex
digit and not an exponent.)

- erik



  reply	other threads:[~2010-02-28  1:59 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
2010-02-28  1:59   ` erik quanstrom [this message]
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=d69aeb1d4bdbff6163069c3ce56888bb@ladd.quanstro.net \
    --to=quanstro@quanstro.net \
    --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).