[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
More patch 2.5.9 hacking
From: |
Stephan T. Lavavej |
Subject: |
More patch 2.5.9 hacking |
Date: |
Wed, 22 Oct 2003 00:14:01 -0700 |
I have fixed the "assertion failed" problem which occurs when patch 2.5.9 is
compiled for MinGW and used on certain files and patches without --binary.
My fix is simple: when HAVE_SETMODE_DOS is enabled, binary mode is *forced*.
The --binary switch is silently ignored.
I would in fact suggest that patch should work with everything in binary at
all times on all systems. Text mode is an abomination from the depths of
1970s evil and we shouldn't have to put up with it anymore. This would
require slightly more extensive changes than I'm comfortable with making, so
I haven't done it.
I tested this using the plain patch 2.5.9 sources and my original patch to
patch:
C:\Temp\test\patch-2.5.9>patchOLD -p1 < patch-2.5.9-mingw.patch
patching file dirname.h
Assertion failed: hunk, file patch.c, line 340
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.
C:\Temp\test\patch-2.5.9>patchNEW -p1 < patch-2.5.9-mingw.patch
patching file dirname.h
patching file util.c
C:\Temp\test\patch-2.5.9>
I now believe that my hacked patch 2.5.9 works as well on MinGW as it does
on GNU/Linux. I can appreciate that my brute force fixes aren't elegant and
aren't suitable for the mainline; nevertheless, they get it working, and
that makes me happy.
I do look forward to a patch 2.5.10 or 2.6 that fixes some or all of these
problems in a better way, so that I don't need to maintain my own
micro-fork. (Manu's fix for the mkdir thing sounds better than my direct
hacking of the source, but since I don't fully understand what's going on,
I'll stick with what I've got until his fix makes it into the official
sources.)
My new patch for patch 2.5.9 is:
diff -aur patch-2.5.9/common.h patch-2.5.9-mingw/common.h
--- patch-2.5.9/common.h 2003-05-18 23:57:36.000000000 -0700
+++ patch-2.5.9-mingw/common.h 2003-10-21 23:42:06.000000000 -0700
@@ -283,7 +283,7 @@
#endif
#if HAVE_SETMODE_DOS
- XTERN int binary_transput; /* O_BINARY if binary i/o is desired */
+# define binary_transput O_BINARY
#else
# define binary_transput 0
#endif
diff -aur patch-2.5.9/dirname.h patch-2.5.9-mingw/dirname.h
--- patch-2.5.9/dirname.h 2001-05-12 08:46:36.000000000 -0700
+++ patch-2.5.9-mingw/dirname.h 2003-10-12 16:34:00.000000000 -0700
@@ -30,7 +30,11 @@
# endif
# ifndef ISSLASH
-# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
+# ifdef __MINGW32__
+# define ISSLASH(C) ((C) == '/' || (C) == '\\')
+# else
+# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
+# endif
# endif
# ifndef FILESYSTEM_PREFIX_LEN
diff -aur patch-2.5.9/patch.c patch-2.5.9-mingw/patch.c
--- patch-2.5.9/patch.c 2003-05-20 06:55:03.000000000 -0700
+++ patch-2.5.9-mingw/patch.c 2003-10-21 23:43:02.000000000 -0700
@@ -752,9 +752,6 @@
verbosity = VERBOSE;
break;
case CHAR_MAX + 3:
-#if HAVE_SETMODE_DOS
- binary_transput = O_BINARY;
-#endif
break;
case CHAR_MAX + 4:
usage (stdout, 0);
diff -aur patch-2.5.9/util.c patch-2.5.9-mingw/util.c
--- patch-2.5.9/util.c 2003-05-20 07:04:53.000000000 -0700
+++ patch-2.5.9-mingw/util.c 2003-10-12 16:34:00.000000000 -0700
@@ -153,7 +153,11 @@
goto rename_succeeded;
}
- if (errno == EXDEV)
+#ifdef __MINGW32__
+ if (errno == EXDEV || errno == EEXIST)
+#else
+ if (errno == EXDEV)
+#endif
{
if (! backup)
{
@@ -879,10 +883,14 @@
for (f = filename; f <= flim; f++)
if (!*f)
{
- mkdir (filename,
- S_IRUSR|S_IWUSR|S_IXUSR
- |S_IRGRP|S_IWGRP|S_IXGRP
- |S_IROTH|S_IWOTH|S_IXOTH);
+#ifdef __MINGW32__
+ mkdir (filename);
+#else
+ mkdir (filename,
+ S_IRUSR|S_IWUSR|S_IXUSR
+ |S_IRGRP|S_IWGRP|S_IXGRP
+ |S_IROTH|S_IWOTH|S_IXOTH);
+#endif
*f = '/';
}
}
Stephan T. Lavavej
http://nuwen.net
- Re: [Mingw-users] Re: MinGW and patch 2.5.9, manubee, 2003/10/13
- Re: [Mingw-users] Re: MinGW and patch 2.5.9, manubee, 2003/10/13
- Re: [Mingw-users] Re: MinGW and patch 2.5.9, Paul Eggert, 2003/10/13
- Re: [Mingw-users] Re: MinGW and patch 2.5.9, Eli Zaretskii, 2003/10/14
- Re: [Mingw-users] Re: MinGW and patch 2.5.9, Stepan Kasal, 2003/10/14
- More patch 2.5.9 hacking,
Stephan T. Lavavej <=
- Re: More patch 2.5.9 hacking, Eli Zaretskii, 2003/10/22
- Re: More patch 2.5.9 hacking, Paul Eggert, 2003/10/22
- Re: More patch 2.5.9 hacking, Eli Zaretskii, 2003/10/22
- Re: [Mingw-users] Re: More patch 2.5.9 hacking, Earnie Boyd, 2003/10/23
- Re: [Mingw-users] More patch 2.5.9 hacking, Benjamin Riefenstahl, 2003/10/23
- Re: [Mingw-users] More patch 2.5.9 hacking, Eli Zaretskii, 2003/10/24
- Re: More patch 2.5.9 hacking, Benjamin Riefenstahl, 2003/10/24
- Re: More patch 2.5.9 hacking, Eli Zaretskii, 2003/10/24
- Re: More patch 2.5.9 hacking, Paul Eggert, 2003/10/24
- Re: More patch 2.5.9 hacking, Benjamin Riefenstahl, 2003/10/25