Attachment "mtimeDiff.patch" to
ticket [634151ffff]
added by
vincentdarley
2003-01-08 17:53:12.
Index: generic/tclIOUtil.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIOUtil.c,v
retrieving revision 1.67
diff -u -r1.67 tclIOUtil.c
--- generic/tclIOUtil.c 6 Dec 2002 23:22:08 -0000 1.67
+++ generic/tclIOUtil.c 8 Jan 2003 10:42:43 -0000
@@ -342,7 +342,6 @@
static Tcl_FSFileAttrStringsProc NativeFileAttrStrings;
static Tcl_FSFileAttrsGetProc NativeFileAttrsGet;
static Tcl_FSFileAttrsSetProc NativeFileAttrsSet;
-static Tcl_FSUtimeProc NativeUtime;
/*
* The only reason these functions are not static is that they
@@ -396,7 +395,7 @@
&TclpObjAccess,
&TclpOpenFileChannel,
&TclpMatchInDirectory,
- &NativeUtime,
+ &TclpUtime,
#ifndef S_IFLNK
NULL,
#else
@@ -4986,33 +4985,6 @@
}
}
return 0;
-}
-
-/*
- * utime wants a normalized, NOT native path. I assume a native
- * version of 'utime' doesn't exist (at least under that name) on NT/2000.
- * If a native function does exist somewhere, then we could use:
- *
- * return native_utime(Tcl_FSGetNativePath(pathPtr),tval);
- *
- * This seems rather strange when compared with stat, lstat, access, etc.
- * all of which want a native path.
- */
-static int
-NativeUtime(pathPtr, tval)
- Tcl_Obj *pathPtr;
- struct utimbuf *tval;
-{
-#ifdef MAC_TCL
- long gmt_offset=TclpGetGMTOffset();
- struct utimbuf local_tval;
- local_tval.actime=tval->actime+gmt_offset;
- local_tval.modtime=tval->modtime+gmt_offset;
- return utime(Tcl_GetString(Tcl_FSGetNormalizedPath(NULL,pathPtr)),
- &local_tval);
-#else
- return utime(Tcl_GetString(Tcl_FSGetNormalizedPath(NULL,pathPtr)),tval);
-#endif
}
/* Everything from here on is contained in this obsolete ifdef */
Index: generic/tclInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
retrieving revision 1.113
diff -u -r1.113 tclInt.h
--- generic/tclInt.h 12 Nov 2002 02:25:05 -0000 1.113
+++ generic/tclInt.h 8 Jan 2003 10:42:44 -0000
@@ -1805,6 +1805,8 @@
Tcl_Obj *pathPtr,
Tcl_LoadHandle *loadHandle,
Tcl_FSUnloadFileProc **unloadProcPtr));
+EXTERN int TclpUtime _ANSI_ARGS_((Tcl_Obj *pathPtr,
+ struct utimbuf *tval));
/*
*----------------------------------------------------------------
Index: mac/tclMacFile.c
===================================================================
RCS file: /cvsroot/tcl/tcl/mac/tclMacFile.c,v
retrieving revision 1.25
diff -u -r1.25 tclMacFile.c
--- mac/tclMacFile.c 9 Oct 2002 11:54:24 -0000 1.25
+++ mac/tclMacFile.c 8 Jan 2003 10:42:45 -0000
@@ -1240,3 +1240,32 @@
/* All native paths are of the same type */
return NULL;
}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TclpUtime --
+ *
+ * Set the modification date for a file.
+ *
+ * Results:
+ * 0 on success, -1 on error.
+ *
+ * Side effects:
+ * None.
+ *
+ *---------------------------------------------------------------------------
+ */
+int
+TclpUtime(pathPtr, tval)
+ Tcl_Obj *pathPtr; /* File to modify */
+ struct utimbuf *tval; /* New modification date structure */
+{
+ long gmt_offset=TclpGetGMTOffset();
+ struct utimbuf local_tval;
+ local_tval.actime=tval->actime+gmt_offset;
+ local_tval.modtime=tval->modtime+gmt_offset;
+ return utime(Tcl_GetString(Tcl_FSGetNormalizedPath(NULL,pathPtr)),
+ &local_tval);
+}
+
Index: tests/cmdAH.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/cmdAH.test,v
retrieving revision 1.29
diff -u -r1.29 cmdAH.test
--- tests/cmdAH.test 11 Jul 2002 08:25:24 -0000 1.29
+++ tests/cmdAH.test 8 Jan 2003 10:42:45 -0000
@@ -1369,6 +1369,22 @@
set modmtime [file mtime $file $newmtime]
expr {$newmtime == $modmtime ? 1 : "$newmtime != $modmtime"}
} 1
+test cmdAH-24.9 {Tcl_FileObjCmd: mtime touch with non-ascii chars} {
+ set oldfile $file
+ # introduce some non-ascii characters.
+ append file \u2022
+ file delete -force $file
+ file rename $oldfile $file
+ set mtime [file mtime $file]
+ after 1100; # pause a sec to notice change in mtime
+ set newmtime [clock seconds]
+ set err [catch {file mtime $file $newmtime} modmtime]
+ file rename $file $oldfile
+ if {$err} {
+ error $modmtime
+ }
+ expr {$newmtime == $modmtime ? 1 : "$newmtime != $modmtime"}
+} 1
removeFile touch.me
# owned
Index: unix/tclUnixFile.c
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tclUnixFile.c,v
retrieving revision 1.28
diff -u -r1.28 tclUnixFile.c
--- unix/tclUnixFile.c 3 Sep 2002 02:01:42 -0000 1.28
+++ unix/tclUnixFile.c 8 Jan 2003 10:42:45 -0000
@@ -813,3 +813,26 @@
/* All native paths are of the same type */
return NULL;
}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TclpUtime --
+ *
+ * Set the modification date for a file.
+ *
+ * Results:
+ * 0 on success, -1 on error.
+ *
+ * Side effects:
+ * None.
+ *
+ *---------------------------------------------------------------------------
+ */
+int
+TclpUtime(pathPtr, tval)
+ Tcl_Obj *pathPtr; /* File to modify */
+ struct utimbuf *tval; /* New modification date structure */
+{
+ return utime(Tcl_FSGetNativePath(pathPtr),tval);
+}
Index: win/makefile.vc
===================================================================
RCS file: /cvsroot/tcl/tcl/win/makefile.vc,v
retrieving revision 1.98
diff -u -r1.98 makefile.vc
--- win/makefile.vc 5 Jan 2003 00:44:24 -0000 1.98
+++ win/makefile.vc 8 Jan 2003 10:42:46 -0000
@@ -709,7 +709,6 @@
install-binaries:
@echo Installing to '$(_INSTALLDIR)'
- @echo.
@echo installing $(TCLLIBNAME)
!if "$(TCLLIB)" != "$(TCLIMPLIB)"
@$(CPY) "$(TCLLIB)" "$(BIN_INSTALL_DIR)\"
Index: win/tclWin32Dll.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWin32Dll.c,v
retrieving revision 1.18
diff -u -r1.18 tclWin32Dll.c
--- win/tclWin32Dll.c 6 Dec 2002 23:22:59 -0000 1.18
+++ win/tclWin32Dll.c 8 Jan 2003 10:42:46 -0000
@@ -92,6 +92,7 @@
*/
NULL,
NULL,
+ (int (__cdecl*)(CONST TCHAR *, struct _utimbuf *)) _utime,
};
static TclWinProcs unicodeProcs = {
@@ -138,6 +139,7 @@
*/
NULL,
NULL,
+ (int (__cdecl*)(CONST TCHAR *, struct _utimbuf *)) _wutime,
};
TclWinProcs *tclWinProcs;
Index: win/tclWinFile.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinFile.c,v
retrieving revision 1.39
diff -u -r1.39 tclWinFile.c
--- win/tclWinFile.c 20 Jul 2002 01:01:41 -0000 1.39
+++ win/tclWinFile.c 8 Jan 2003 10:42:46 -0000
@@ -2222,3 +2222,37 @@
Tcl_DStringFree(&dsNorm);
return nextCheckpoint;
}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TclpUtime --
+ *
+ * Set the modification date for a file.
+ *
+ * Results:
+ * 0 on success, -1 on error.
+ *
+ * Side effects:
+ * None.
+ *
+ *---------------------------------------------------------------------------
+ */
+int
+TclpUtime(pathPtr, tval)
+ Tcl_Obj *pathPtr; /* File to modify */
+ struct utimbuf *tval; /* New modification date structure */
+{
+ int res;
+ /*
+ * Windows uses a slightly different structure name and, possibly,
+ * contents, so we have to copy the information over
+ */
+ struct _utimbuf buf;
+
+ buf.actime = tval->actime;
+ buf.modtime = tval->modtime;
+
+ res = (*tclWinProcs->utimeProc)(Tcl_FSGetNativePath(pathPtr),&buf);
+ return res;
+}
Index: win/tclWinInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinInt.h,v
retrieving revision 1.17
diff -u -r1.17 tclWinInt.h
--- win/tclWinInt.h 29 Oct 2002 14:17:58 -0000 1.17
+++ win/tclWinInt.h 8 Jan 2003 10:42:46 -0000
@@ -100,6 +100,9 @@
GET_FILEEX_INFO_LEVELS, LPVOID);
BOOL (WINAPI *createHardLinkProc)(CONST TCHAR*, CONST TCHAR*,
LPSECURITY_ATTRIBUTES);
+
+ INT (__cdecl *utimeProc)(CONST TCHAR*, struct _utimbuf *);
+
} TclWinProcs;
EXTERN TclWinProcs *tclWinProcs;