Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2000-10-26
08:23 • Closed ticket [218525ffff]: difference in behavior of "file exists <name... artifact: d9a1a4e86b user: welch
01:01 • New ticket [218525ffff]. artifact: 5bd3f097b4 user: nobody

difference in behavior of "file exists <name>" when <name> r

Closed / Fixed218525ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:01:41
OriginalBugID: 889 Bug
Version: 8.0.3
SubmitDate: '1998-12-02'
LastModified: '1999-08-20'
Severity: MED
Status: Released
Submitter: admin
ChangedBy: hobbs
OS: All Windows
OSVersion: NA
Machine: NA
FixedDate: '1999-08-20'
FixedInVersion: 8.2
ClosedDate: '2000-10-25'


I have noticed that there is a difference in the processing of the
"file exists <name>" command in the 8.0.3 version when <name> refers
to removable media.  On the 8.0p2 version, the command would just
return a result.  But the 8.0.3 version displays a dialog containing
"There is no disk in the drive.  Please insert a disk into drive
<name>."  This new action is undesirable and unwanted.  The
application code should be given the opportunity to react to the
success or failure of the command.
 
 Tested on:
   Windows NT 4.0 SR3
   Windows 95
 
From the 8.0p2 console and with no diskette in drive A:
 % file exists a:
 % 0
 
From the 8.0.3 console and with no diskette in drive A:
 % file exists a:
 - --> dialog is displayed.  pressed "Abort" button
 % 0


This sounds like a difference between the VC++ and Borland run-time libraries. 
 I think it can be fixed by registering an appropriate exception handler.  
This should be logged as a bug.  --Scott
-----
comments from syd polk:

OK, I think I have two fixes.

First of all, in tclIO.c, in TranslateOutputEOL, there is a case for
TCL_TRANSLATE_CRLF. The for loop is not checking for running off of the end
of the dst buffer. What happens is that the last character the previous
interation is a CR. It stuffs both CR and LF into the buffer, and returns
one more than the max size. The calling routine, WriteChars, notes the
extra character and saves of the split. It then decrements the buffer size
which it passes back in because the buffer already has an LF in it. The
TCL_TRANSLATE_CRLF case then ignores that fact and it sets up an endless
procession of extra carriage returns.

The loop needs to be set up to stop when running out of source or when
running out of dst.


The other problem is much more subtle and not nearly so important.

In WriteChars, the TranslateOutputEOL routine returns whether or not it saw
a carriage return. This information is passed to CheckFlush. On a
line-buffered channel, CheckFlush uses this information to determine
whether or not to actually flush the channel.

The problem is that the flag is never reset. So if there are lines longer
than the buffer size after the first line feed is seen, every write will
flush.

Also, in the case of TCL_TRANSLATE_CR or TCL_TRANSLATE_LF, the code does a
memcpy, and then traverses the buffer again to find returns. Shouldn't it
copy character by character and note returns on the way, thus saving a
complete traversal of the code? Right now, it looks like it is faster to
write out characters with crlf than the other two.

I will have a patch for these problems by tomorrow morning.
--
The above comments don't seem to relate to this bug id, but this
problem has been fixed in newer releases, also with the addition
of a file volumes command. 
-- 08/20/1999 hobbs
welch Closed ticket [218525ffff]. [History diff]2000-10-26 08:23:20
Log in (anonymous is fine) to add a comment.