FORMAT prefix parameter '#' not handled properly
Charles Turner
chturne@gmail.com
Fri Oct 7 20:22:00 GMT 2011
Evaluating (format #t "~#$" 3.14159) should return 3.1, since the length
of the argument list is 1 (3.14159) and the # prefix parameter tells
FORMAT to print that many fractional digits. Here are a couple of
examples with the fix in place,
#|kawa:2|# (format #t "~#$" 3.14159)
3.1
#|kawa:3|# (format #t "~#$" 3.14159 1 2)
3.142
The current behaviour is to throw a NullPointerException, this is
because the call dfmt.resolve(null, 0); in LispFormat#LispFormat calls
getParam, which doesn't handle a args value of null properly. The patch
for LispFormat makes a small modification to avoid calling this
dfmt.resolve method, even if you fix getParam to handle null properly,
this method replaces the LispRealFormat instance with a FixedRealFormat
instance, having done that, we forget to check the paramCount stuff.
I'm not 100% happy with this fix, but it seems to work okay, I'm finding
the logic in LispFormat a bit hard to follow for now.
I seem to have changed the indentation in LispFormat, no matter how I
change the indentation to match the original, svn diff keeps saying it's
different, sorry about that. I just ended up accepting how Emacs indents
the line break in the middle of a param list.
The ReportFormat patch attached includes the fix for getParam. If this
is acceptable, I'll send some test cases and change logs.
Charles.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ReportFormat.patch
Type: text/x-patch
Size: 757 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/kawa/attachments/20111007/9decfc1b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LispFormat.patch
Type: text/x-patch
Size: 961 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/kawa/attachments/20111007/9decfc1b/attachment-0001.bin>
More information about the Kawa
mailing list