[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MinGW and patch 2.5.9
From: |
Stephan T. Lavavej |
Subject: |
MinGW and patch 2.5.9 |
Date: |
Sun, 12 Oct 2003 17:37:20 -0700 |
patch 2.5.9 does not work when compiled with MinGW/MSYS. This is also true
of earlier versions of patch.
The following patch makes patch 2.5.9 compile and work properly when
compiled with MinGW/MSYS. It does not change patch's behavior on any other
systems.
It would be nice if the next version of patch incorporated these changes so
that it would work unmodified with MinGW/MSYS.
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:07:11.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/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:17:57.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 = '/';
}
}
I think I reverse-engineered these changes out of the messy UnxUtils source,
but I don't entirely remember now. I don't really know what the changes do
other than that they fix the problems.
There is another problem with patch and MinGW: sometimes an assertion will
fail (patch.c line 340). This appears to be related to CR/LF issues, and
passing --binary to patch makes it work.
I subscribe to mingw-users but not to bug-patch and bug-gnu-utils.
Stephan T. Lavavej
http://stl.caltech.edu
- MinGW and patch 2.5.9,
Stephan T. Lavavej <=