Re: [tkined] Bug in tnmMapEvent.c

From: Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Date: Wed Oct 10 2001 - 16:22:51 MET DST


>>>>> Pete Flugstad writes:

[...]

Pete> I believe this is related to the following #if, just above that:

Pete> #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 8 \ &&
Pete> TCL_RELEASE_SERIAL > 2 #define TnmStat TclStat #else #define
Pete> TnmStat stat #endif

Pete> This #if fails, so TnmStat is #def'd to be "stat", which is
Pete> causing the warning above.

Pete> In looking through the Tcl header files, I find TclStat there,
Pete> so I'm guessing the #if should be:

Pete> #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 3 &&
Pete> TCL_RELEASE_SERIAL >= 2

Pete> at the very least? (What version was TclStat introduced?)

I think it was one of the 8.2.X releases. I checked 8.3.0 and it is
already defining TclStat. So I simplified the check.

Pete> It also complains about various other minor things:
Pete> signed/unsigned comparisons, passing NULL and various other
Pete> things that are mostly innocuous. Is it worth your while to
Pete> send these as well?

If the compiler detects problems that might be serious bugs, please
submit a patch. I personally prefer unified context diffs (diff -u)
relative to the latext cvs version (just use cvs diff).

Pete> But, it did spit out a error about:

Pete> .\..\tnm\generic\tnmMapEvent.c(580) : warning C4700: local
Pete> variable 'interp' used without having been initialized

Pete> Sure enough, I look there and:

[...]

Pete> This has to be a bug. The order of the last two lines needs to
Pete> be reversed: interp needs to be assigned to before it's passed
Pete> to Tcl_Preserve.

Yep. Below is the patch which I have just checked into our CVS.

Index: tnmInt.h
===================================================================
RCS file: /usr/home/schoenw/CVS/scotty/tnm/generic/tnmInt.h,v
retrieving revision 1.17
diff -U10 -r1.17 tnmInt.h
--- tnmInt.h 2001/02/05 13:03:08 1.17
+++ tnmInt.h 2001/10/10 14:14:27
@@ -48,21 +48,21 @@
 /*
  *----------------------------------------------------------------
  * The following functions are not officially exported by Tcl.
  * They are used anyway because they make this code simpler and
  * platform independent.
  *----------------------------------------------------------------
  */
 
 #define TnmGetTime TclpGetTime
 #define TnmCreateDirectory TclpCreateDirectory
-#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 8 && TCL_RELEASE_SERIAL > 2
+#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 2
 #define TnmStat TclStat
 #else
 #define TnmStat stat
 #endif
 
 EXTERN void
 TnmGetTime _ANSI_ARGS_((Tcl_Time *timePtr));
 
 EXTERN int
 TnmCreateDirectory _ANSI_ARGS_((char *path));
Index: tnmMapEvent.c
===================================================================
RCS file: /usr/home/schoenw/CVS/scotty/tnm/generic/tnmMapEvent.c,v
retrieving revision 1.10
diff -U10 -r1.10 tnmMapEvent.c
--- tnmMapEvent.c 2001/01/19 11:15:51 1.10
+++ tnmMapEvent.c 2001/10/10 14:06:04
@@ -570,22 +570,22 @@
     char buf[20];
     int code;
     Tcl_DString tclCmd;
     char *startPtr, *scanPtr;
     Tcl_Interp *interp;
 
     if (!eventPtr->mapPtr || !eventPtr->mapPtr->interp) {
         return TCL_OK;
     }
 
- Tcl_Preserve(interp);
     interp = eventPtr->mapPtr->interp;
+ Tcl_Preserve(interp);
 
     Tcl_DStringInit(&tclCmd);
 
     for (bindPtr = bindList; bindPtr; bindPtr = bindPtr->nextPtr) {
 
         if (bindPtr->type != (eventPtr->type & TNM_MAP_EVENT_MASK) ||
             Tcl_StringMatch(eventPtr->eventName, bindPtr->pattern) == 0) {
             continue;
         }
 

/js

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.



This archive was generated by hypermail 2b29 : Thu Jan 03 2002 - 14:56:27 MET