[tcljava-dev] SubstCmd
Brought to you by:
mdejong
From: Justin R. <ju...@ha...> - 2007-04-11 03:52:42
|
I'm having a problem with the subst command, in which the java version differs from the c version. In the C Tcl: % set str "Hello\rWorld\r" World % puts [string length $str] 12 % puts [string length [subst $str] ] 12 You can see that the \r stays in the string. While in Jacl: % set str "Hello\rWorld\r" World % puts [string length $str] 12 % puts [string length [subst $str] ] 10 If you delve into the string, it's missing the \r characters on Jacl. There's an explicit line in SubstCmd.java that excludes this character. The comment nearby says that it might not be compatible on a Mac. I can't say either way if it incompatible with the Mac, but I can say for sure that it's incompatible with Tcl. Does anyone know why this bit was added? Can it be removed? I use subst for variable substitution on string passed into me, and I can't have it missing characters. My work around was to rewrite the subst command, but since SubstCmd has package private privileges, I couldn't just extend it. I had to copy and paste from SubstCmd.java. Is there a reason that so many of the jacl/tcljava classes don't define themselves as public classes? If a specific class shouldn't be extended then it could be defined as final. justin |