[setup patch] Fix cygwin-mode compilation.
Max Bowsher
maxb@ukf.net
Wed Jan 15 17:13:00 GMT 2003
It's occasionally useful to compile setup.exe linked with cygwin1.dll, to
debug a crash that occurs within msvcrt.dll.
There was a missing bit of code in mkdir.cc, and a clashing typedef in
io_stream.h.
Along the way, I bumped into a direct include of <windows.h> in our
proppage.h, and pushed it through our win32.h, where we care about windows.h
namespace pollution (min/max) which otherwise can cause libstdc++ headers
fail.
Please check the fragment I've put into mkdir.cc.
I've never actually used stat() before!
Ok to commit?
Max.
----------------------------------
Index: mkdir.cc
===================================================================
RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/mkdir.cc,v
retrieving revision 2.5
diff -u -p -r2.5 mkdir.cc
--- mkdir.cc 26 Jun 2002 21:35:16 -0000 2.5
+++ mkdir.cc 15 Jan 2003 17:10:56 -0000
@@ -22,6 +22,11 @@ static const char *cvsid =
#if defined(WIN32) && !defined (_CYGWIN_)
#include "win32.h"
+#else
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
#endif
#include <stdio.h>
@@ -61,17 +66,29 @@ mkdir_p (int isadir, const char *in_path
}
}
#else
+ struct stat st;
strcpy (path, in_path);
- /* stat */
- /* if file exists and is a dir return */
- /* if we want a dir at this point
- call makedir
- if ok return 0
- if fails due to present file,
- rmove the file and return 1
- else if fails due to missing fail/path
- end block */
+ if (stat(path,&st) == 0 && S_ISDIR(st.st_mode))
+ return 0;
+
+ if (isadir)
+ {
+ if (mkdir (path, 0777))
+ return 0;
+ if (errno != ENOENT)
+ {
+ if (errno == EEXIST)
+ {
+ fprintf (stderr,
+ "warning: deleting \"%s\" so I can make a directory there\n",
+ path);
+ if (unlink (path))
+ return mkdir_p (isadir, path);
+ }
+ return 1;
+ }
+ }
#endif
for (c = path; *c; c++)
Index: io_stream.h
===================================================================
RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/io_stream.h,v
retrieving revision 2.9
diff -u -p -r2.9 io_stream.h
--- io_stream.h 5 May 2002 04:02:01 -0000 2.9
+++ io_stream.h 15 Jan 2003 16:53:30 -0000
@@ -31,7 +31,9 @@ class IOStreamProvider;
*/
//Where is this defined?
+#if defined(_WIN32) && ! defined(__CYGWIN__)
typedef signed long ssize_t;
+#endif
#if __GNUC__
#define _ATTR_(foo) __attribute__ foo
Index: proppage.h
===================================================================
RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/proppage.h,v
retrieving revision 2.3
diff -u -p -r2.3 proppage.h
--- proppage.h 21 Sep 2002 09:36:46 -0000 2.3
+++ proppage.h 15 Jan 2003 16:53:31 -0000
@@ -20,7 +20,7 @@
// PropSheet class to implement a single page of the property sheet.
-#include <windows.h>
+#include "win32.h"
#include <prsht.h>
#include "window.h"
-------------------------------
More information about the Cygwin-apps
mailing list