Tcl Source Code

Artifact [cba096cc0f]
Login

Artifact cba096cc0fd0c1f5c6b3e34d931d8ebf982bdced:

Attachment "seh_return.patch" to ticket [525746ffff] added by mdejong 2002-03-07 12:58:55.
2002-03-06  Mo DeJong  <[email protected]>

	* win/tclWin32Dll.c (TclpCheckStackSpace):
	* win/tclWinFCmd.c (DoRenameFile, DoCopyFile): Replace
	hard coded constants with Win32 symbolic names.
	Move control flow statements out of __try blocks
	since the documentation indicates it is frowned upon.

Index: win/tclWin32Dll.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWin32Dll.c,v
retrieving revision 1.13
diff -u -r1.13 tclWin32Dll.c
--- win/tclWin32Dll.c	8 Feb 2002 02:52:54 -0000	1.13
+++ win/tclWin32Dll.c	7 Mar 2002 05:53:29 -0000
@@ -340,6 +340,8 @@
 int
 TclpCheckStackSpace()
 {
+    int retval = 0;
+
     /*
      * We can recurse only if there is at least TCL_WIN_STACK_THRESHOLD
      * bytes of stack space left.  alloca() is cheap on windows; basically
@@ -349,10 +351,13 @@
 
     __try {
 	alloca(TCL_WIN_STACK_THRESHOLD);
-	return 1;
-    } __except (1) {}
+	retval = 1;
+    } __except (EXCEPTION_EXECUTE_HANDLER) {}
 
-    return 0;
+    /*
+     * Avoid using control flow statements in the SEH guarded block!
+     */
+    return retval;
 }
 
 
Index: win/tclWinFCmd.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinFCmd.c,v
retrieving revision 1.22
diff -u -r1.22 tclWinFCmd.c
--- win/tclWinFCmd.c	8 Feb 2002 02:52:55 -0000	1.22
+++ win/tclWinFCmd.c	7 Mar 2002 05:53:30 -0000
@@ -164,17 +164,24 @@
 				 * (native). */
 {    
     DWORD srcAttr, dstAttr;
+    int retval = -1;
 
     /*
-     * Would throw an exception under NT if one of the arguments is a 
-     * char block device.
+     * The moveFileProc below would throw an exception under NT
+     * if one of the arguments is a char block device.
      */
 
     __try {
 	if ((*tclWinProcs->moveFileProc)(nativeSrc, nativeDst) != FALSE) {
-	    return TCL_OK;
+	    retval = TCL_OK;
 	}
-    } __except (-1) {}
+    } __except (EXCEPTION_CONTINUE_EXECUTION) {}
+
+    /*
+     * Avoid using control flow statements in the SEH guarded block!
+     */
+    if (retval != -1)
+        return retval;
 
     TclWinConvertError(GetLastError());
 
@@ -432,9 +439,11 @@
    CONST TCHAR *nativeSrc,	/* Pathname of file to be copied (native). */
    CONST TCHAR *nativeDst)	/* Pathname of file to copy to (native). */
 {
+    int retval = -1;
+
     /*
-     * Would throw an exception under NT if one of the arguments is a char
-     * block device.
+     * The copyFileProc below would throw an exception under NT if one
+     * of the arguments is a char block device.
      */
 
     /* 
@@ -463,9 +472,15 @@
     
     __try {
 	if ((*tclWinProcs->copyFileProc)(nativeSrc, nativeDst, 0) != FALSE) {
-	    return TCL_OK;
+	    retval = -1;
 	}
-    } __except (-1) {}
+    } __except (EXCEPTION_CONTINUE_EXECUTION) {}
+
+    /*
+     * Avoid using control flow statements in the SEH guarded block!
+     */
+    if (retval != -1)
+        return retval;
 
     TclWinConvertError(GetLastError());
     if (Tcl_GetErrno() == EBADF) {