cygwin POSIX pathname fix

Mumit Khan khan@xraylith.wisc.EDU
Mon Apr 19 18:13:00 GMT 1999


We have been discussing using POSIX-only pathnames for Cygwin, in part
to avoid issues like ``gcc -print-prog-name=ld'', but also to be more
Unix-like. With the new DIR_SEPARATOR_2 macro, GCC is now able to use
both directory separators, and so it's a pretty safe change.

The change to GET_ENV_PATH_LIST converts GCC_EXEC_PREFIX etc to POSIX
format if specified using win32 pathname syntax.

This patch requires the change to cpp to preserve leading // that I had 
sent earlier today and approved by Dave Brolley (but not committed yet).

To do the pathname conversion correctly however, we need to insert Cygwin 
specific pathname handling code in the GCC driver.

Chris Faylor, could you please take a look?

Bootstrap tested, native and canadian cross. Diff against 990419 CVS.

Mon Apr 19 20:02:08 1999  Mumit Khan  <khan@xraylith.wisc.edu>

	* i386/xm-cygwin.h (HAVE_BCOPY): Delete unneeded macro.
	(HAVE_BZERO): Likewise.
	(HAVE_BCMP): Likewise.
	(HAVE_RINDEX): Likewise.
	(HAVE_INDEX): Likewise.
	(DIR_SEPARATOR_2): Define.
	(GET_ENV_PATH_LIST): Turn path lists into POSIX.
	(PATH_SEPARATOR): Use ':'.

Index: config/i386/xm-cygwin.h
===================================================================
RCS file: /cvs/egcs/egcs/gcc/config/i386/xm-cygwin.h,v
retrieving revision 1.5
diff -u -3 -p -r1.5 xm-cygwin.h
--- config/i386/xm-cygwin.h	1999/02/09 23:52:06	1.5
+++ config/i386/xm-cygwin.h	1999/04/20 01:02:01
@@ -21,11 +21,6 @@ Boston, MA 02111-1307, USA. */
 
 #define EXECUTABLE_SUFFIX ".exe"
 #define NO_SYS_SIGLIST 1
-#define HAVE_BCOPY 1
-#define HAVE_BZERO 1
-#define HAVE_BCMP 1
-#define HAVE_RINDEX 1
-#define HAVE_INDEX 1
 
 /* We support both "/" and "\" since everybody tests both but we
    default to "/".  This is important because if gcc produces Win32
@@ -34,33 +29,28 @@ Boston, MA 02111-1307, USA. */
    slashes so using a forward slash shouldn't be problematic from the
    perspective of wanting gcc to produce native Win32 paths. */
 #define DIR_SEPARATOR '/'
+#define DIR_SEPARATOR_2 '\\'
 
-/* If we allow both '/' and '\' as dir separators, then
-   allow both unix and win32 PATH syntax. */
+/* Convert win32 style path lists to POSIX style for consistency. */ 
 #undef GET_ENV_PATH_LIST
 #define GET_ENV_PATH_LIST(VAR,NAME)					\
 do {									\
   char *_epath;								\
-  char *_win32epath;							\
-  _epath = _win32epath = getenv (NAME);					\
-  /* if we have a posix path list, convert to win32 path list */	\
+  char *_posixepath;							\
+  _epath = _posixepath = getenv (NAME);					\
+  /* if we have a posix path list, convert to posix path list */	\
   if (_epath != NULL && *_epath != 0					\
-      && cygwin32_posix_path_list_p (_epath))				\
+      && ! cygwin_posix_path_list_p (_epath))				\
     {									\
       char *p;								\
-      _win32epath = (char *) xmalloc					\
-	(cygwin32_posix_to_win32_path_list_buf_size (_epath));		\
-      cygwin32_posix_to_win32_path_list (_epath, _win32epath);		\
-      for (p = _win32epath; p && *p; ++p)				\
-        {								\
-	  if (*p == '\\')						\
-	    *p = '/';							\
-	}								\
+      _posixepath = (char *) xmalloc					\
+	(cygwin_win32_to_posix_path_list_buf_size (_epath));		\
+      cygwin_win32_to_posix_path_list (_epath, _posixepath);		\
     }									\
-  (VAR) = _win32epath;							\
+  (VAR) = _posixepath;							\
 } while (0)
 
-#define PATH_SEPARATOR ';'
+#define PATH_SEPARATOR ':'
 
 /* This is needed so that protoize will compile.  */
 #ifndef POSIX

Regards,
Mumit



More information about the Gcc-patches mailing list