From: Lloyd Zusman <ljz@asfast.com>
To: supervision@list.skarnet.org
Subject: [skalibs] long_fmt fails with FMT_LEN (was: Why no negative numbers in the *_fmt routines?)
Date: Tue, 7 Jun 2011 12:08:17 +0000 (UTC) [thread overview]
Message-ID: <loom.20110607T140118-653@post.gmane.org> (raw)
In-Reply-To: <loom.20110607T134908-107@post.gmane.org>
Lloyd Zusman <ljz <at> asfast.com> writes:
> Lloyd Zusman <ljz <at> asfast.com> writes:
>
> > [ ... ]
> > the integer-based *_fmt routines do not format negative numbers.
>
> I'm sorry. I missed long_fmt.c and I misread fmtscan.h. I was getting
> errors with negative numbers, and I mistakenly thought that this was
> due to int_fmt failing with values < 0.
Actually, this problem is due to a bug in long_fmt. It doesn't properly
handle the FMT_LEN argument when the value to be formatted is negative.
This is evident in the source code:
unsigned int long_fmt (char *fmt, long n)
{
if (n >= 0) return ulong_fmt(fmt, n) ;
*fmt++ = '-' ;
return 1 + ulong_fmt(fmt, -n) ;
}
This should be changed as follows:
unsigned int long_fmt (char *fmt, long n)
{
if (n >= 0) return ulong_fmt(fmt, n) ;
if (fmt != 0) *fmt++ = '-' ;
return 1 + ulong_fmt(fmt, -n) ;
}
--
Lloyd Zusman
ljz@asfast.com
God bless you.
next prev parent reply other threads:[~2011-06-07 12:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-07 9:40 [skalibs] Why no negative numbers in the *_fmt routines? Lloyd Zusman
2011-06-07 11:55 ` Lloyd Zusman
2011-06-07 12:08 ` Lloyd Zusman [this message]
2011-06-07 13:52 ` [skalibs] long_fmt fails with FMT_LEN (was: Why no negative numbers in the *_fmt routines?) Laurent Bercot
2011-06-08 0:13 ` Lloyd Zusman
2011-06-11 13:31 ` [skalibs] Can't post on the skaware mailing list (was: long_fmt fails with FMT_LEN) Lloyd Zusman
2011-06-11 15:37 ` Laurent Bercot
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=loom.20110607T140118-653@post.gmane.org \
--to=ljz@asfast.com \
--cc=supervision@list.skarnet.org \
/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).