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]

file system handling patch for libiberty


Hello,
This patch adds filesys.h to help mask the differences between Unix and the Microsoft 
OSes and changes basename.c and choose-temp.c to use it.

Changelog:

2000-04-18 Mark Elbrecht <snowball3@bigfoot.com>

	* include/filesys.h: New file. Adds macros for DIR_SEPARATOR,
	  DIR_SEPARATOR_2, IS_DIR_SEPARATOR, PATH_SEPARATOR,
	  and IS_PATH_SEPARATOR.
	* libiberty/basename.c (DIR_SEPARATOR, DIR_SEPARATOR_2,
	  HAVE_DOS_BASED_FILE_SYSTEM): Delete. Now defined by
	  including filesys.h.
	* libiberty/choose-temp.c (choose_temp_base): Use IS_DIR_SEPARATOR.
	  (make_temp_file): Likewise.

*** /dev/null	Tue Apr 18 18:34:06 2000
--- include/filesys.h	Tue Apr 18 18:07:58 2000
***************
*** 0 ****
--- 1,64 ----
+ /* Macros that hide the differences between Unix, Windows,
+    and other file systems.
+ 
+    Copyright (C) 2000 Free Software Foundation, Inc.
+ 
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+  
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+ 
+ #ifndef FILE_SYS_H
+ #define FILE_SYS_H
+ 
+ #ifndef IN_GCC
+ 
+ /* Define the directory separator.  */
+ #ifndef DIR_SEPARATOR
+ #define DIR_SEPARATOR '/'
+ #endif
+ 
+ /* DOS, Windows, and OS/2 also use '\' as a directory separator.
+    Also define HAVE_DOS_BASED_FILE_SYSTEM to enable code that handles
+    drive letters and other oddities.  */
+ #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+   defined (__OS2__)
+ #define HAVE_DOS_BASED_FILE_SYSTEM
+ #ifndef DIR_SEPARATOR_2 
+ #define DIR_SEPARATOR_2 '\\'
+ #endif
+ #endif
+ 
+ /* Define IS_DIR_SEPARATOR.  Use this macro in place of testing for '/'. */
+ #ifndef DIR_SEPARATOR_2
+ # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+ #else /* DIR_SEPARATOR_2 */
+ # define IS_DIR_SEPARATOR(ch) \
+ 	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+ #endif /* DIR_SEPARATOR_2 */
+ 
+ /* Define PATH_SEPARATOR. Unix and Unix emulators (like Cygwin) use ':',
+    while DOS, Windows, and OS/2 use ';'.  */
+ #if (defined (_WIN32) && !defined (__CYGWIN__)) || \
+   defined (__MSDOS__) || defined (__DJGPP__) || defined (__OS2__)
+ #define PATH_SEPARATOR ';'
+ #else
+ #define PATH_SEPARATOR ':'
+ #endif
+ 
+ /* Define IS_PATH_SEPARATOR.  Use this macro in place of testing for ':'.  */
+ #define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+ 
+ #endif /* IN_GCC */
+ 
+ #endif /* FILE_SYS_H */
+ 
*** libiberty/basename.c.orig	Wed Oct 13 03:18:10 1999
--- libiberty/basename.c	Tue Apr 18 18:33:20 2000
*************** BUGS
*** 20,47 ****
  
  #include "ansidecl.h"
  #include "libiberty.h"
  #include <ctype.h>
  
- #ifndef DIR_SEPARATOR
- #define DIR_SEPARATOR '/'
- #endif
- 
- #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
-   defined (__OS2__)
- #define HAVE_DOS_BASED_FILE_SYSTEM
- #ifndef DIR_SEPARATOR_2 
- #define DIR_SEPARATOR_2 '\\'
- #endif
- #endif
- 
- /* Define IS_DIR_SEPARATOR.  */
- #ifndef DIR_SEPARATOR_2
- # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
- #else /* DIR_SEPARATOR_2 */
- # define IS_DIR_SEPARATOR(ch) \
- 	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
- #endif /* DIR_SEPARATOR_2 */
- 
  char *
  basename (name)
       const char *name;
--- 20,28 ----
  
  #include "ansidecl.h"
  #include "libiberty.h"
+ #include "filesys.h"
  #include <ctype.h>
  
  char *
  basename (name)
       const char *name;
*** libiberty/choose-temp.c.orig	Sat Sep 25 09:11:12 1999
--- libiberty/choose-temp.c	Tue Apr 18 17:58:02 2000
***************
*** 1,5 ****
  /* Utility to pick a temporary filename prefix.
!    Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
  
  This file is part of the libiberty library.
  Libiberty is free software; you can redistribute it and/or
--- 1,5 ----
  /* Utility to pick a temporary filename prefix.
!    Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
  
  This file is part of the libiberty library.
  Libiberty is free software; you can redistribute it and/or
*************** Boston, MA 02111-1307, USA.  */
*** 45,61 ****
  #endif
  
  #include "libiberty.h"
! extern int mkstemps ();
! 
! #ifndef IN_GCC
! #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN__) && ! defined 
(_UWIN))
! #define DIR_SEPARATOR '\\'
! #endif
! #endif
  
! #ifndef DIR_SEPARATOR
! #define DIR_SEPARATOR '/'
! #endif
  
  /* On MSDOS, write temp files in current dir
     because there's no place else we can expect to use.  */
--- 45,53 ----
  #endif
  
  #include "libiberty.h"
! #include "filesys.h"
  
! extern int mkstemps ();
  
  /* On MSDOS, write temp files in current dir
     because there's no place else we can expect to use.  */
*************** choose_temp_base ()
*** 130,137 ****
    strcpy (temp_filename, base);
  
    if (len != 0
!       && temp_filename[len-1] != '/'
!       && temp_filename[len-1] != DIR_SEPARATOR)
      temp_filename[len++] = DIR_SEPARATOR;
    strcpy (temp_filename + len, TEMP_FILE);
  
--- 122,128 ----
    strcpy (temp_filename, base);
  
    if (len != 0
!       && !IS_DIR_SEPARATOR (temp_filename[len-1]))
      temp_filename[len++] = DIR_SEPARATOR;
    strcpy (temp_filename + len, TEMP_FILE);
  
*************** make_temp_file (suffix)
*** 183,190 ****
    strcpy (temp_filename, base);
  
    if (base_len != 0
!       && temp_filename[base_len-1] != '/'
!       && temp_filename[base_len-1] != DIR_SEPARATOR)
      temp_filename[base_len++] = DIR_SEPARATOR;
    strcpy (temp_filename + base_len, TEMP_FILE);
  
--- 174,180 ----
    strcpy (temp_filename, base);
  
    if (base_len != 0
!       && !IS_DIR_SEPARATOR (temp_filename[base_len-1]))
      temp_filename[base_len++] = DIR_SEPARATOR;
    strcpy (temp_filename + base_len, TEMP_FILE);
  


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