Tcl Source Code

View Ticket
Login
Ticket UUID: 1107673
Title: tclIO.c (CVS): Tcl_NextHashEntry should be used
Type: Bug Created on: 2005-01-23 07:24:08
Submitter: nobody Assigned to: andreas_kupries
Subsystem: 25. Channel System Severity:
Priority: 1 Zero Last modified: 2005-01-25 05:12:17
Status: Open Closed by:
Resolution: None Closed on:
Version: None
Description:
tcl/generic/tclIO.c:

... static void DeleteChannelTable (clientData, interp):

   580      for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch);
   581              hPtr != (Tcl_HashEntry *) NULL;
   582              hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch)) {

        The second use of `Tcl_FirstHashEntry' seems to be a mistake.

... int Tcl_GetChannelNamesEx (interp, pattern):

  8752      for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch);
  8753              hPtr != (Tcl_HashEntry *) NULL;
  8754              hPtr = Tcl_NextHashEntry(&hSearch)) {
User Comments:
dkf added on 2005-01-24 16:25:30:
Logged In: YES 
user_id=79902

Noting that it is safe to do a loop{delete;next} - it is an
explicitly supported scenario.

andreas_kupries added on 2005-01-25 05:12:17:
Logged In: YES 
user_id=75003

The code as is is OK. You get the first hash entry, delete,
and when we get the first entry again it will be a different
entry.

So it is not a bug per se.

I was not aware that the loop(delete,next) scenario is
supported. That could be a new thing. I dimly remember that
I changed code somewhere to the idiom as shown here because
the other failed.

Donal, note that according to annotate you were the last one
to touch this code, Nov 29 last year. There is however no
entry in the ChangeLog about this. ... Hm. Janitorial fixes
according to cvs log, rev 1.80.  But the CVS diff 1.79/1.80
does not show any difference at this location. Ok, something
is lying to me.

Still, this is not a bug. At most a minor style thing.