Front page | perl.perl6.internals |
Postings from December 2001
Parrot_sprintf
Thread Next
From:
Brent Dax
Date:
December 20, 2001 22:02
Subject:
Parrot_sprintf
Message ID:
FJELLKOPEAGHOOODKEDPKELOCOAA.brentdax@cpan.org
The attached patch implements a Parrot_sprintf function. It doesn't do
quite what you think--it just wraps the system sprintf. However, it
provides I and F sizes and is designed to interact with STRINGs. For
example:
FLOATVAL f;
INTVAL i;
STRING *str;
Parrot_sprintf(&str, "Decimal: %Id\nOctal: %Io\nDecimal: %Ff\nExponent:
%Fe", i, i, f, f);
It keeps away from messing up flags--%+3.2Ff will do what it should.
However, it has one big weakness. Currently, you'll get a buffer
overflow if the resulting string is greater than 1024 characters.
The patch doesn't actually change anything to use Parrot_sprintf; it
just defines the function and the Configure machinery needed to support
it. It's currently in string.[hc]; I'm not sure if this is the right
place. I won't be surprised if this isn't high-quality enough to
actually be applied.
--Brent Dax
brentdax@cpan.org
Configure pumpking for Perl 6
"Nothing important happened today."
--George III of England's diary entry for 4-Jul-1776
Thread Next
-
Parrot_sprintf
by Brent Dax