This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FORMAT prefix parameter '#' not handled properly


The following patch fixes this problem, and produces no regressions.

The only slightly odd behaviour is that

(format #t "~#f" java.lang.Math:PI)
  => 3.

SBCL returns 3.141592653589793. I'll look at the spec tomorrow to see what the final word is on this, but Kawa stuffs the argument length into the "decimals" field of LispRealFormat when it encounters a '$' and into the "width" field when it encounters an 'f'. So the discrepancy is easy to identify, I'm just not sure what to do about that right now.

At least a NullPointerException isn't throw on encountering a '#' though.

All the stuff in the constructor of LispRealFormat appears to never get used (apart from unnecessarily when an object is instantiated of course), I moved those check into a new method that can be called to update the argsUsed field.

(The ReportFormat patch is no longer necessary, though I suppose the args parameter should tested against null as a matter of course)

Charles.
Index: gnu/kawa/functions/LispFormat.java
===================================================================
--- gnu/kawa/functions/LispFormat.java	(revision 7065)
+++ gnu/kawa/functions/LispFormat.java	(working copy)
@@ -151,6 +151,7 @@
 		    dfmt.arg7 = getParam(stack, speci+6);
 		  }
 	      }
+	    dfmt.updateUsed();
 	    dfmt.showPlus = seenAt;
 	    dfmt.internalPad = seenColon;
 	    if (dfmt.argsUsed == 0)
@@ -919,6 +920,7 @@
     return start;
   }
 
+  @Override
   public String toString ()
   {
     StringBuffer sbuf = new StringBuffer();
@@ -1052,8 +1054,8 @@
       }
     else if (! skipIfFalse)
       {
-	int index = getParam(this.param, LispFormat.PARAM_FROM_LIST,
-					args, start);
+       int index = getParam(this.param, LispFormat.PARAM_FROM_LIST, 
+			    args, start);
 	if (param == LispFormat.PARAM_FROM_LIST)  start++;
 	if (index < 0 || index >= choices.length)
 	  {
@@ -1202,9 +1204,8 @@
   boolean internalPad;
   /** Twice the number of args consumed; odd if any arg is PARAM_FROM_COUNT. */
   int argsUsed;
-
-  LispRealFormat()
-  {
+  
+  protected void updateUsed() {
     argsUsed = (arg1 == LispFormat.PARAM_FROM_COUNT
 		|| arg2 == LispFormat.PARAM_FROM_COUNT
 		|| arg3 == LispFormat.PARAM_FROM_COUNT

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]