This is the mail archive of the kawa@sources.redhat.com 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]

Re: bug in call-with-output-string ?


At 04:55 PM 9/30/2001 -0700, kamysh@uroam.com wrote:
>it seems, there is a bug in realization of `call-with-output-string' in
>kawa-1.6.94: it does not allow more than 126 symbols to be `displayed.
>...

Wow.  Tough looking problem.  I tracked it down to this:

1) PrettWriter.java:41:
   public static int initialBufferSize = 126;

2) PrettyWriter.ensureSpaceInBuffer:717
   Sees that the buffer is full when the 127th character is to be output,
   and so calls outputPartialLine().

3) PrettyWriter.outputPartialLine expects PrettyWriter.out to be non-null 
so that it can output the line as collected so far.

But!

4) gnu.mapping.CharArrayOutPort is an OutPort whose OutPort.base Writer is 
null, which is what it ends up giving to PrettyWriter:
     super(null, false, "<string>");

The fix looks fairly simple (CharArrayOutPort needs to give OutPort a 
CharArrayWriter to write onto).

Attached is an untested (or even compiled) rewrite of 
kawa.standard.call_with_output_string.  It is based on 
call_with_output_file (which should work and you might want use instead of 
_with_string as a workaround).

That is only a hack as it doesn't fix CharArrayOutPort which is used by 
gnu.kawa.functions.Format.formatToString.

jim

----------------------------------------------------------------
James P. White                 Netscape DevEdge Champion for IFC
IFC Exchange   *   Insanely great Java   *   http://www.ifcx.org
jim@pagesmiths.com Pagesmiths' home is http://www.pagesmiths.com
package kawa.standard;
import kawa.lang.*;
import gnu.mapping.*;
             
public class call_with_output_string extends Procedure1
{
  public Object apply2 (final Object proc)
  {
    try
      {
	final java.io.Writer os = new java.io.CharArrayWriter();
	final OutPort port = new OutPort(os, "<string>");
	final Object result = ((Procedure)proc).apply1 (port);
	port.close ();
	return result;
      }
    catch (final java.io.IOException e)
      {
	throw new WrappedException(e);
      }
  }
}

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