This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH/Ada: Fix DIR_SEPARATOR bug on win32 targets


This patch

2003-11-10  Arnaud Charlet  <charlet@act-europe.fr>

	PR 12950
	* osint.ads, osint.adb (Relocate_Path, Executable_Suffix): New
	functions. Used to handle dynamic prefix relocation, via set_std_prefix.
	Replace GNAT_ROOT by GCC_ROOT.

exposed a latent bug in the handling of DOS/Win32 filenames, resulting
in failure to build gnatlib (Bug Box raised when compiling
a-caldel.adb). DOS based file systems need to recognize '\\' as well as
'/' as directory separators. The former is necessary for handling PATH
and other environmental variables.

This fixes, by stealing some defines from libiberty's filenames.h.  It
would be cleaner to just include filenames.h, but that can't be done
when IN_RTS.



Changelog

2003-11-13  Danny Smith  <dannysmith@users.sourceforge.net>


	* adaint.c (HAVE_DOS_BASED_FILE_SYSTEM): Define, if not already
	defined.
	(IS_DIR_SEPARATOR): Likewise.
	(__gnat_get_current_dir): Use it.
	(__gnat_is_absolute_path): Likewise. Simplify test for DOS drive
	prefix.
	Remove inclusion of ctype.h.

Index: adaint.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/adaint.c,v
retrieving revision 1.22
diff -c -3 -p -r1.22 adaint.c
*** adaint.c	10 Nov 2003 17:29:58 -0000	1.22
--- adaint.c	13 Nov 2003 07:22:06 -0000
***************
*** 76,82 ****
  #ifdef __MINGW32__
  #include "mingw32.h"
  #include <sys/utime.h>
- #include <ctype.h>
  #else
  #ifndef VMS
  #include <utime.h>
--- 76,81 ----
*************** struct vstring
*** 189,194 ****
--- 188,209 ----
  #define DIR_SEPARATOR '/'
  #endif
  
+ /* This is all in libiberty filenames.h, but we can't include when IN_RTS, */ 
+ #if defined(__MSDOS__) || defined(_WIN32) || defined(__EMX__) \
+     || defined (__CYGWIN__)
+ #ifndef HAVE_DOS_BASED_FILE_SYSTEM
+ #define HAVE_DOS_BASED_FILE_SYSTEM 1
+ #endif
+ #endif
+ 
+ #ifndef IS_DIR_SEPARATOR
+ # ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ #  define IS_DIR_SEPARATOR(CH) (((CH) == '/') || ((CH) == '\\'))
+ # else
+ #  define IS_DIR_SEPARATOR(CH) ((CH) == '/')
+ # endif /* HAVE_DOS_BASED_FILE_SYSTEM */
+ #endif /* IS_DIR_SEPARATOR */
+ 
  char __gnat_dir_separator = DIR_SEPARATOR;
  
  char __gnat_path_separator = PATH_SEPARATOR;
*************** __gnat_get_current_dir (char *dir, int *
*** 482,488 ****
  
     *length = strlen (dir);
  
!    if (dir [*length - 1] != DIR_SEPARATOR)
       {
         dir [*length] = DIR_SEPARATOR;
         ++(*length);
--- 497,503 ----
  
     *length = strlen (dir);
  
!    if (!IS_DIR_SEPARATOR (dir [*length - 1]))
       {
         dir [*length] = DIR_SEPARATOR;
         ++(*length);
*************** __gnat_file_exists (char *name)
*** 1374,1382 ****
  int
  __gnat_is_absolute_path (char *name)
  {
!   return (*name == '/' || *name == DIR_SEPARATOR
! #if defined (__EMX__) || defined (MSDOS) || defined (WINNT)
!       || (strlen (name) > 1 && isalpha (name[0]) && name[1] == ':')
  #endif
  	  );
  }
--- 1389,1397 ----
  int
  __gnat_is_absolute_path (char *name)
  {
!   return (IS_DIR_SEPARATOR (*name)
! #if defined(HAVE_DOS_BASED_FILE_SYSTEM)
!     || (name [0] && name [1] == ':')
  #endif
  	  );
  }
*************** __gnat_locate_regular_file (char *file_n
*** 1853,1859 ****
  
    /* If file_name include directory separator(s), try it first as
       a path name relative to the current directory */
!   for (ptr = file_name; *ptr && *ptr != '/' && *ptr != DIR_SEPARATOR; ptr++)
      ;
  
    if (*ptr != 0)
--- 1868,1875 ----
  
    /* If file_name include directory separator(s), try it first as
       a path name relative to the current directory */
!   for (ptr = file_name;
!        *ptr && !IS_DIR_SEPARATOR (*ptr); ptr++)
      ;
  
    if (*ptr != 0)
*************** __gnat_locate_regular_file (char *file_n
*** 1881,1887 ****
          *ptr++ = *path_val++;
  
        ptr--;
!       if (*ptr != '/' && *ptr != DIR_SEPARATOR)
          *++ptr = DIR_SEPARATOR;
  
        strcpy (++ptr, file_name);
--- 1897,1903 ----
          *ptr++ = *path_val++;
  
        ptr--;
!       if (!IS_DIR_SEPARATOR (*ptr))
          *++ptr = DIR_SEPARATOR;
  
        strcpy (++ptr, file_name);

http://personals.yahoo.com.au - Yahoo! Personals
New people, new possibilities. FREE for a limited time.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]