Re: [tcljava-dev] Re: [tcljava-user] Tcl/Java 1.3.0 release is online.
Brought to you by:
mdejong
From: Mo D. <md...@un...> - 2003-03-23 03:32:53
|
On Tue, 18 Mar 2003 09:54:17 -0800 Mo DeJong <md...@un...> wrote: > > tcl/string.test > > > > ==== string-6.14 string is alnum, unicode FAILED > > ==== Contents of test case: > > > > string is alnum abc? > > > > ---- Result was: > > 0 > > ---- Result should have been: > > 1 > > ==== string-6.14 FAILED I have been thinking about this one and I think it is an encoding issue with the source command. Could you try this patch and see if it fixes the problem? As I said, I don't see this error on my system so I need others to test this. Index: src/jacl/tcl/lang/Interp.java =================================================================== RCS file: /cvsroot/tcljava/tcljava/src/jacl/tcl/lang/Interp.java,v retrieving revision 1.43 diff -u -r1.43 Interp.java --- src/jacl/tcl/lang/Interp.java 13 Mar 2003 22:28:10 -0000 1.43 +++ src/jacl/tcl/lang/Interp.java 23 Mar 2003 02:04:41 -0000 @@ -2352,7 +2352,7 @@ throws TclException { - String fileContent; // Contains the content of the file. + TclObject fileContent; // Contains the content of the file. fileContent = readScriptFromFile(s); @@ -2439,32 +2439,36 @@ *---------------------------------------------------------------------- */ -private String +private TclObject readScriptFromFile( String s) // The name of the file. { - File sourceFile; - FileInputStream fs; + FileChannel file; + TclObject result; + int charactersRead = -1; + + file = new FileChannel(); + if (file.getEncoding() == null) { + result = TclByteArray.newInstance(); + } else { + // FIXME: set default buffer size to about the + // size of the file? + result = TclString.newInstance(new StringBuffer(64)); + } try { - sourceFile = FileUtil.getNewFileObj(this, s); - fs = new FileInputStream(sourceFile); - } catch (TclException e) { - resetResult(); - return null; - } catch (FileNotFoundException e) { - return null; - } catch (SecurityException sec_e) { - return null; + file.open(this, s, TclIO.RDONLY); + charactersRead = file.read(this, result, TclIO.READ_ALL, 0); + TclIO.unregisterChannel(this, file); + } catch (TclException ex) { + // FIXME: Catch Tcl error in open + } catch (IOException ex) { + // FIXME: do something with this. } - try { - byte charArray[] = new byte[fs.available()]; - fs.read(charArray); - return new String(charArray); - } catch (IOException e) { - return null; - } finally { - closeInputStream(fs); + if (charactersRead >= 0) { + return result; + } else { + return null; } } |