>>>> "Ben" == Ben Wing <ben(a)666.com>
writes:
Ben> adrian, this is very likely a bug caused by martin, because
Ben> he simply removed the utime support under windows when he
Ben> reworked it. [please be more careful wrt windows, martin!]
Ben> here is some code out of my mule workspace that should fix
Ben> it. i can't exactly generate a clean patch because
Ben> everything has changed a lot, so i've appended a partial a
Ben> patch. [sorry, it's somewhat untested] in addition you'll
Ben, after changing nt.[ch] as instructed and applying the patch atend
I get the following. I spent some time to investigate what I could
have done wrong. Nothing too obvious, I hope.
I have a "cvs diff src" of my workspace at end.
What to do next?
cd c:\Hacking\xemacs\xemacs-21.2\nt\
nmake /f xemacs.mak DEBUG_XEMACS="1" GUNG_HO="1"
HAVE_JPEG="1" HAVE_PNG="1" HAVE_TIFF="1"
HAVE_XFACE="1" HAVE_XPM="1" INSTALL_DIR="c:\Program
Files\XEmacs\XEmacs-$(XEMACS_VERSION_STRING)"
JPEG_DIR="c:\Hacking\libs4xemacs\jpeg-6b"
MAKEINFO="c:\Hacking\texinfo-4.0\makeinfo\makeinfo.exe"
PNG_DIR="c:\Hacking\libs4xemacs\libpng-1.0.2"
TIFF_DIR="c:\Hacking\libs4xemacs\tiff-v3.4" USE_PORTABLE_DUMPER="1"
XPM_DIR="c:\Hacking\libs4xemacs\xpm-3.4k"
ZLIB_DIR="c:\Hacking\libs4xemacs\zlib" all
Compilation started at Sun Apr 08 23:02:45 2001
Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
WARNING: Compiling without dependency information.
Creating c:\Hacking\xemacs\xemacs-21.2\nt\..\lib-src\config.values
--------------------------------------------------------------------
OS: Windows_NT
XEmacs 21.2-b46 \"Urania\" configured for `i586-pc-win32'.
Building XEmacs in \"c:\\Hacking\\xemacs\\xemacs-21.2\\nt\".
Using compiler \"cl -nologo -W3 -Od -Zi -MDd\".
Installing XEmacs in \"c:\\Program Files\\XEmacs\\XEmacs-21.2-b46\".
Package path is \"~\\.xemacs;;c:\\Program Files\\XEmacs\\site-packages;c:\\Program
Files\\XEmacs\\xemacs-packages\".
Compiling in support for Microsoft Windows native GUI.
--------------------------------------------------------------------
WARNING: Compiling without GTK support.
WARNING: As of xemacs-21.2-b44
WARNING: gtk-xemacs is not supported on MSWindows (mingw or msvc).
WARNING: Yes, we know that gtk has been ported to native MSWindows
WARNING: but XEmacs is not yet ready to use that port.
--------------------------------------------------------------------
Compiling in support for XPM images.
Compiling in support for GIF images.
Compiling in support for PNG images.
Compiling in support for TIFF images.
Compiling in support for JPEG images.
Compiling in support for X-Face message headers.
Compiling in support for toolbars.
Compiling in support for dialogs.
Compiling in support for widgets.
Compiling in support for native sounds.
Compiling in fast dired implementation.
Using minimal tagbits.
Using indexed lrecord implementation.
Using portable dumper.
Using system malloc.
Using DLL version of C runtime library
Compiling in extra debug checks. XEmacs will be slow!
--------------------------------------------------------------------
copy config.h c:\Hacking\xemacs\xemacs-21.2\nt\..\src
1 file(s) copied.
copy Emacs.ad.h c:\Hacking\xemacs\xemacs-21.2\nt\..\src
1 file(s) copied.
copy paths.h c:\Hacking\xemacs\xemacs-21.2\nt\..\src
1 file(s) copied.
cd c:\Hacking\xemacs\xemacs-21.2\nt\..\lib-src
make-dump-id.c
c:\Hacking\xemacs\xemacs-21.2\nt\..\lib-src\../src/systime.h(237) : error C2146: syntax
error : missing ')' before identifier 'path'
c:\Hacking\xemacs\xemacs-21.2\nt\..\lib-src\../src/systime.h(237) : error C2061: syntax
error : identifier 'path'
c:\Hacking\xemacs\xemacs-21.2\nt\..\lib-src\../src/systime.h(237) : error C2059: syntax
error : ';'
c:\Hacking\xemacs\xemacs-21.2\nt\..\lib-src\../src/systime.h(237) : error C2059: syntax
error : ','
c:\Hacking\xemacs\xemacs-21.2\nt\..\lib-src\../src/systime.h(237) : error C2059: syntax
error : ')'
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.
Compilation exited abnormally with code 2 at Sun Apr 08 23:02:52
Ben> have to add this line to nt.h:
Ben> int mswindows_utime (Lisp_Object path, struct utimbuf *times);
Ben> and this code to nt.c:
Ben> static void
Ben> convert_from_time_t (time_t time, FILETIME * pft)
Ben> {
Ben> long double tmp;
Ben> if (!init)
Ben> {
Ben> /* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */
Ben> SYSTEMTIME st;
Ben> st.wYear = 1970;
Ben> st.wMonth = 1;
Ben> st.wDay = 1;
Ben> st.wHour = 0;
Ben> st.wMinute = 0;
Ben> st.wSecond = 0;
Ben> st.wMilliseconds = 0;
Ben> SystemTimeToFileTime (&st, &utc_base_ft);
Ben> utc_base = (long double) utc_base_ft.dwHighDateTime
Ben> * 4096 * 1024 * 1024 + utc_base_ft.dwLowDateTime;
Ben> init = 1;
Ben> }
Ben> /* time in 100ns units since 1-Jan-1601 */
Ben> tmp = (long double) time * 1e7 + utc_base;
pft-> dwHighDateTime = (DWORD) (tmp / (4096.0 * 1024 * 1024));
pft-> dwLowDateTime = (DWORD) (tmp - (4096.0 * 1024 * 1024) *
pft-> dwHighDateTime);
Ben> }
Ben> int
Ben> mswindows_utime (Lisp_Object path, struct utimbuf *times)
Ben> {
Ben> struct utimbuf deftime;
Ben> HANDLE fh;
Ben> FILETIME mtime;
Ben> FILETIME atime;
Ben> Extbyte *filename;
Ben> if (times == NULL)
Ben> {
Ben> deftime.modtime = deftime.actime = time (NULL);
Ben> times = &deftime;
Ben> }
Ben> LISP_STRING_TO_EXTERNAL (path, filename, Qmswindows_tstr);
Ben> /* Need write access to set times. */
Ben> fh = CreateFile (filename, GENERIC_WRITE, FILE_SHARE_READ |
FILE_SHARE_WRITE,
Ben> 0, OPEN_EXISTING, 0, NULL);
Ben> if (fh)
Ben> {
Ben> convert_from_time_t (times->actime, &atime);
Ben> convert_from_time_t (times->modtime, &mtime);
Ben> if (!SetFileTime (fh, NULL, &atime, &mtime))
Ben> {
Ben> CloseHandle (fh);
Ben> errno = EACCES;
Ben> return -1;
Ben> }
Ben> CloseHandle (fh);
Ben> }
Ben> else
Ben> {
Ben> errno = EINVAL;
Ben> return -1;
Ben> }
Ben> return 0;
Ben> }
Ben> Adrian Aichner wrote:
>
> >>>>> "APA" == Adrian Aichner
<Adrian.Aichner(a)t-online.de> writes:
>
APA> Torgny has located the problem.
>
APA> Thanks, Torgny!
>
APA> What is the right approach to fix this?
>
>> Martin,
>
>> you've worked on this last.
>
>> The current code in 21.1.14 does work on
Windows 2000 while the code
>> in 21.2-b46 does not!
>
>> I'm willing to test any suggestions you
have.
>
>> Best regards,
>
>> Adrian
>
APA> Best regards,
>
APA> Adrian
>
APA> From: Torgny Nyblom <torgny(a)linux.nu>
APA> Subject: Re: XEmacs 21.1-b46 pop3.el?
APA> Newsgroups: comp.emacs.xemacs
APA> Date: 03 Apr 2001 17:00:07 +0200
APA> Organization: Telenordia
APA> Message-ID: <elvaowp4.fsf(a)nyblom.org>
APA> References: <u24gt9fi.fsf(a)nyblom.org>
<ulmpshzyx.fsf(a)rapier.ecf.teradyne.com>
APA> Xref:
news.t-online.com comp.emacs.xemacs:52365
>
APA> Adrian Aichner <adrian(a)xemacs.org>
writes:
>
>> >> FWIW, I have seen this problem also
in 21.2-b46 build on native
>> >> Windows 2000.
Torgny> know if the problem exists in others) pop3.el. The problem
Torgny> is that when I try to use 'pop3-leave-mail-on-server t' I
Torgny> get this error message:
>
APA> [...]
>
APA> After some time away I found what the problem
is. In the function
APA> 'pop3-save-uidls' in pop3.el 'copy-file' is called with
KEEP-TIME to 't' this
APA> breaks Win2000. If I remove this 't' everything workes fine.
>
APA> --
APA> Torgny Nyblom | torgny(a)linux.nu
APA> ===============================
APA> My keyboard has an F1 key. Where is the NASCAR key?
APA> ===============================
APA> ----------
>
APA> --
APA> Adrian Aichner Teradyne GmbH, European Design Center
APA> Integra Test Division Telephone +49/89/41861(0)-208
APA> Dingolfinger Strasse 2 Fax +49/89/41861-115
APA> D-81673 MUENCHEN E-mail adrian.aichner(a)teradyne.com
>
>> --
>> Adrian Aichner
>> mailto:adrian@xemacs.org
>>
http://www.xemacs.org/
Ben> --
Ben> ben
Ben> I'm sometimes slow in getting around to reading my mail, so if you
Ben> want to reach me faster, call 520-661-6661.
Ben> See
http://www.666.com/ben/chronic-pain/ for the hell I've been
Ben> through.Index: src/fileio.c
Ben> ===================================================================
Ben> RCS file: /usr/CVSroot/XEmacs/xemacs/src/fileio.c,v
Ben> retrieving revision 1.51.2.34.6.2
Ben> diff -u -r1.51.2.34.6.2 fileio.c
Ben> --- src/fileio.c 2001/02/27 17:21:21 1.51.2.34.6.2
Ben> +++ src/fileio.c 2001/04/05 05:15:23
Ben> @@ -54,6 +54,7 @@
Ben> #endif /* HPUX */
Ben> #ifdef WIN32_NATIVE
Ben> +#include "nt.h"
Ben> #define IS_DRIVE(x) isalpha (x)
Ben> /* Need to lower-case the drive letter, or else expanded
Ben> filenames will sometimes compare inequal, because
Ben> @@ -1676,16 +1667,6 @@
Ben> return;
Ben> }
Ben> -/* A slightly higher-level interface than `set_file_times' */
Ben> -static int
Ben> -lisp_string_set_file_times (Lisp_Object filename,
Ben> - EMACS_TIME atime, EMACS_TIME mtime)
Ben> -{
Ben> - char *ext_filename;
Ben> - LISP_STRING_TO_EXTERNAL (filename, ext_filename, Qfile_name);
Ben> - return set_file_times (ext_filename, atime, mtime);
Ben> -}
Ben> -
Ben> DEFUN ("copy-file", Fcopy_file, 2, 4,
Ben> "fCopy file: \nFCopy %s to file: \np\nP", /*
Ben> Copy FILENAME to NEWNAME. Both args must be strings.
Ben> @@ -1823,7 +1804,7 @@
Ben> EMACS_TIME atime, mtime;
Ben> EMACS_SET_SECS_USECS (atime, st.st_atime, 0);
Ben> EMACS_SET_SECS_USECS (mtime, st.st_mtime, 0);
Ben> - if (lisp_string_set_file_times (newname, atime, mtime))
Ben> + if (set_file_times (newname, atime, mtime))
Ben> report_file_error ("I/O error", list1 (newname));
Ben> }
Ben> chmod ((const char *) XSTRING_DATA (newname),
Ben> Index: src/sysdep.c
Ben> ===================================================================
Ben> RCS file: /usr/CVSroot/XEmacs/xemacs/src/sysdep.c,v
Ben> retrieving revision 1.32.2.44.4.2
Ben> diff -u -r1.32.2.44.4.2 sysdep.c
Ben> --- src/sysdep.c 2001/03/14 16:16:22 1.32.2.44.4.2
Ben> +++ src/sysdep.c 2001/04/05 05:15:57
Ben> @@ -3342,17 +3289,26 @@
Ben> access to those functions goes through the following. */
Ben> int
Ben> -set_file_times (char *filename, EMACS_TIME atime, EMACS_TIME mtime)
Ben> +set_file_times (Lisp_Object path, EMACS_TIME atime, EMACS_TIME mtime)
Ben> {
Ben> -#if defined (HAVE_UTIME)
Ben> +#if defined (WIN32_NATIVE)
Ben> + struct utimbuf utb;
Ben> + utb.actime = EMACS_SECS (atime);
Ben> + utb.modtime = EMACS_SECS (mtime);
Ben> + return mswindows_utime (path, &utb);
Ben> +#elif defined (HAVE_UTIME)
Ben> struct utimbuf utb;
Ben> + Extbyte *filename;
Ben> utb.actime = EMACS_SECS (atime);
Ben> utb.modtime = EMACS_SECS (mtime);
Ben> + LISP_STRING_TO_EXTERNAL (path, filename, Qfile_name);
Ben> return utime (filename, &utb);
Ben> #elif defined (HAVE_UTIMES)
Ben> struct timeval tv[2];
Ben> + Extbyte *filename;
Ben> tv[0] = atime;
Ben> tv[1] = mtime;
Ben> + LISP_STRING_TO_EXTERNAL (path, filename, Qfile_name);
Ben> return utimes (filename, tv);
Ben> #else
Ben> /* No file times setting function available. */
Ben> Index: src/systime.h
Ben> ===================================================================
Ben> RCS file: /usr/CVSroot/XEmacs/xemacs/src/systime.h,v
Ben> retrieving revision 1.8.2.6.6.1
Ben> diff -u -r1.8.2.6.6.1 systime.h
Ben> --- src/systime.h 2001/02/20 12:22:01 1.8.2.6.6.1
Ben> +++ src/systime.h 2001/04/05 05:15:57
Ben> @@ -63,10 +63,16 @@
Ben> #endif /* WIN32_NATIVE */
Ben> +/* struct utimbuf */
Ben> +
Ben> #ifdef HAVE_UTIME
Ben> # include <utime.h>
Ben> #endif
Ben> +#ifdef WIN32_NATIVE
Ben> +# include <sys/utime.h>
Ben> +#endif
Ben> +
Ben> #if defined(HAVE_TZNAME) && !defined(WIN32_NATIVE) &&
!defined(CYGWIN)
Ben> #ifndef tzname /* For SGI. */
Ben> extern char *tzname[]; /* RS6000 and others want it this way. */
Ben> @@ -228,7 +234,7 @@
Ben> #define EMACS_SET_SECS_USECS(time, secs, usecs) \
Ben> (EMACS_SET_SECS (time, secs), EMACS_SET_USECS (time, usecs))
Ben> -int set_file_times (char *filename, EMACS_TIME atime, EMACS_TIME mtime);
Ben> +int set_file_times (Lisp_Object path, EMACS_TIME atime, EMACS_TIME mtime);
Ben> void get_process_times (double *user_time, double *system_time,
Ben> double *real_time);
cd c:\Hacking\xemacs\xemacs-21.2\
cvs diff src
Compilation started at Sun Apr 08 23:22:54 2001 +0200 (W. Europe Daylight Time)
? src/dump-id.c
? src/fileio.anno
? src/NEEDTODUMP
cvs server: Diffing src
Index: src/fileio.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/fileio.c,v
retrieving revision 1.51.2.38
diff -u -r1.51.2.38 fileio.c
--- src/fileio.c 2001/02/27 04:50:31 1.51.2.38
+++ src/fileio.c 2001/04/08 21:23:07
@@ -54,6 +54,7 @@
#endif /* HPUX */
#ifdef WIN32_NATIVE
+#include "nt.h"
#define IS_DRIVE(x) isalpha (x)
/* Need to lower-case the drive letter, or else expanded
filenames will sometimes compare inequal, because
@@ -1676,16 +1677,6 @@
return;
}
-/* A slightly higher-level interface than `set_file_times' */
-static int
-lisp_string_set_file_times (Lisp_Object filename,
- EMACS_TIME atime, EMACS_TIME mtime)
-{
- char *ext_filename;
- LISP_STRING_TO_EXTERNAL (filename, ext_filename, Qfile_name);
- return set_file_times (ext_filename, atime, mtime);
-}
-
DEFUN ("copy-file", Fcopy_file, 2, 4,
"fCopy file: \nFCopy %s to file: \np\nP", /*
Copy FILENAME to NEWNAME. Both args must be strings.
@@ -1823,7 +1814,7 @@
EMACS_TIME atime, mtime;
EMACS_SET_SECS_USECS (atime, st.st_atime, 0);
EMACS_SET_SECS_USECS (mtime, st.st_mtime, 0);
- if (lisp_string_set_file_times (newname, atime, mtime))
+ if (set_file_times (newname, atime, mtime))
report_file_error ("I/O error", list1 (newname));
}
chmod ((const char *) XSTRING_DATA (newname),
Index: src/nt.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/nt.c,v
retrieving revision 1.17.2.28
diff -u -r1.17.2.28 nt.c
--- src/nt.c 2001/03/08 08:19:37 1.17.2.28
+++ src/nt.c 2001/04/08 21:23:09
@@ -2242,6 +2242,76 @@
close_file_data (&executable);
}
+static void
+convert_from_time_t (time_t time, FILETIME * pft)
+{
+ long double tmp;
+
+ if (!init)
+ {
+ /* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */
+ SYSTEMTIME st;
+
+ st.wYear = 1970;
+ st.wMonth = 1;
+ st.wDay = 1;
+ st.wHour = 0;
+ st.wMinute = 0;
+ st.wSecond = 0;
+ st.wMilliseconds = 0;
+
+ SystemTimeToFileTime (&st, &utc_base_ft);
+ utc_base = (long double) utc_base_ft.dwHighDateTime
+ * 4096 * 1024 * 1024 + utc_base_ft.dwLowDateTime;
+ init = 1;
+ }
+
+ /* time in 100ns units since 1-Jan-1601 */
+ tmp = (long double) time * 1e7 + utc_base;
+ pft->dwHighDateTime = (DWORD) (tmp / (4096.0 * 1024 * 1024));
+ pft->dwLowDateTime = (DWORD) (tmp - (4096.0 * 1024 * 1024) *
+ pft->dwHighDateTime);
+}
+
+int
+mswindows_utime (Lisp_Object path, struct utimbuf *times)
+{
+ struct utimbuf deftime;
+ HANDLE fh;
+ FILETIME mtime;
+ FILETIME atime;
+ Extbyte *filename;
+
+ if (times == NULL)
+ {
+ deftime.modtime = deftime.actime = time (NULL);
+ times = &deftime;
+ }
+
+ LISP_STRING_TO_EXTERNAL (path, filename, Qmswindows_tstr);
+ /* Need write access to set times. */
+ fh = CreateFile (filename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ 0, OPEN_EXISTING, 0, NULL);
+ if (fh)
+ {
+ convert_from_time_t (times->actime, &atime);
+ convert_from_time_t (times->modtime, &mtime);
+ if (!SetFileTime (fh, NULL, &atime, &mtime))
+ {
+ CloseHandle (fh);
+ errno = EACCES;
+ return -1;
+ }
+ CloseHandle (fh);
+ }
+ else
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ return 0;
+}
+
/* Close the system structures associated with the given file. */
void
close_file_data (file_data *p_file)
Index: src/nt.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/nt.h,v
retrieving revision 1.6.2.6
diff -u -r1.6.2.6 nt.h
--- src/nt.h 2000/06/13 01:40:06 1.6.2.6
+++ src/nt.h 2001/04/08 21:23:09
@@ -105,6 +105,7 @@
void set_process_dir (const char * dir);
time_t convert_time (FILETIME ft);
+int mswindows_utime (Lisp_Object path, struct utimbuf *times);
extern void init_ntproc (void);
extern void term_ntproc (int unused);
Index: src/sysdep.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/sysdep.c,v
retrieving revision 1.32.2.49
diff -u -r1.32.2.49 sysdep.c
--- src/sysdep.c 2001/03/13 00:22:10 1.32.2.49
+++ src/sysdep.c 2001/04/08 21:23:12
@@ -3342,17 +3342,26 @@
access to those functions goes through the following. */
int
-set_file_times (char *filename, EMACS_TIME atime, EMACS_TIME mtime)
+set_file_times (Lisp_Object path, EMACS_TIME atime, EMACS_TIME mtime)
{
-#if defined (HAVE_UTIME)
+#if defined (WIN32_NATIVE)
struct utimbuf utb;
utb.actime = EMACS_SECS (atime);
utb.modtime = EMACS_SECS (mtime);
+ return mswindows_utime (path, &utb);
+#elif defined (HAVE_UTIME)
+ struct utimbuf utb;
+ Extbyte *filename;
+ utb.actime = EMACS_SECS (atime);
+ utb.modtime = EMACS_SECS (mtime);
+ LISP_STRING_TO_EXTERNAL (path, filename, Qfile_name);
return utime (filename, &utb);
#elif defined (HAVE_UTIMES)
struct timeval tv[2];
+ Extbyte *filename;
tv[0] = atime;
tv[1] = mtime;
+ LISP_STRING_TO_EXTERNAL (path, filename, Qfile_name);
return utimes (filename, tv);
#else
/* No file times setting function available. */
Index: src/systime.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/systime.h,v
retrieving revision 1.8.2.7
diff -u -r1.8.2.7 systime.h
--- src/systime.h 2001/02/09 06:08:20 1.8.2.7
+++ src/systime.h 2001/04/08 21:23:13
@@ -63,10 +63,16 @@
#endif /* WIN32_NATIVE */
+/* struct utimbuf */
+
#ifdef HAVE_UTIME
# include <utime.h>
#endif
+#ifdef WIN32_NATIVE
+# include <sys/utime.h>
+#endif
+
#if defined(HAVE_TZNAME) && !defined(WIN32_NATIVE) && !defined(CYGWIN)
#ifndef tzname /* For SGI. */
extern char *tzname[]; /* RS6000 and others want it this way. */
@@ -228,7 +234,7 @@
#define EMACS_SET_SECS_USECS(time, secs, usecs) \
(EMACS_SET_SECS (time, secs), EMACS_SET_USECS (time, usecs))
-int set_file_times (char *filename, EMACS_TIME atime, EMACS_TIME mtime);
+int set_file_times (Lisp_Object path, EMACS_TIME atime, EMACS_TIME mtime);
void get_process_times (double *user_time, double *system_time,
double *real_time);
cvs server: Diffing src/m
cvs server: Diffing src/s
Compilation exited abnormally with code 1 at Sun Apr 08 23:23:27
--
Adrian Aichner
mailto:adrian@xemacs.org
http://www.xemacs.org/