This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


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

Fix slash problem on win32 in libiberty fnmatch.c


This patch adopts the gdb-style SLASH_P() notation internally and defines it
for WIN32 vs. others.

Tue May 11 20:41:06 PDT 1999  Todd Whitesel  (toddpw@wrs.com)

	* fnmatch.c (fnmatch): Use SLASH_P() to handle both flavors of slashes
	on win32.

#!/bin/sh

patch -b -c -p 0 <<':END:PATCH:HUNKS:'
Index: fnmatch.c
diff -c fnmatch.c.orig fnmatch.c
*** fnmatch.c.orig	Tue May 11 20:32:43 1999
--- fnmatch.c	Tue May 11 20:37:25 1999
***************
*** 47,52 ****
--- 47,57 ----
  #include <fnmatch.h>
  #include <ctype.h>
  
+ #if defined(WIN32) || defined(_WIN32)
+ #define SLASH_P(x) ((x)=='/' || (x)=='\\')
+ #else
+ #define SLASH_P(x) ((x)=='/')
+ #endif
  
  /* Comment out all this code if we are using the GNU C Library, and are not
     actually compiling the library itself.  This code is part of the GNU C
***************
*** 86,95 ****
  	case '?':
  	  if (*n == '\0')
  	    return FNM_NOMATCH;
! 	  else if ((flags & FNM_FILE_NAME) && *n == '/')
  	    return FNM_NOMATCH;
  	  else if ((flags & FNM_PERIOD) && *n == '.' &&
! 		   (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
  	    return FNM_NOMATCH;
  	  break;
  
--- 91,100 ----
  	case '?':
  	  if (*n == '\0')
  	    return FNM_NOMATCH;
! 	  else if ((flags & FNM_FILE_NAME) && SLASH_P(*n))
  	    return FNM_NOMATCH;
  	  else if ((flags & FNM_PERIOD) && *n == '.' &&
! 		   (n == string || ((flags & FNM_FILE_NAME) && SLASH_P(n[-1]))))
  	    return FNM_NOMATCH;
  	  break;
  
***************
*** 105,115 ****
  
  	case '*':
  	  if ((flags & FNM_PERIOD) && *n == '.' &&
! 	      (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
  	    return FNM_NOMATCH;
  
  	  for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
! 	    if (((flags & FNM_FILE_NAME) && *n == '/') ||
  		(c == '?' && *n == '\0'))
  	      return FNM_NOMATCH;
  
--- 110,120 ----
  
  	case '*':
  	  if ((flags & FNM_PERIOD) && *n == '.' &&
! 	      (n == string || ((flags & FNM_FILE_NAME) && SLASH_P(n[-1]))))
  	    return FNM_NOMATCH;
  
  	  for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
! 	    if (((flags & FNM_FILE_NAME) && SLASH_P(*n)) ||
  		(c == '?' && *n == '\0'))
  	      return FNM_NOMATCH;
  
***************
*** 135,141 ****
  	      return FNM_NOMATCH;
  
  	    if ((flags & FNM_PERIOD) && *n == '.' &&
! 		(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
  	      return FNM_NOMATCH;
  
  	    not = (*p == '!' || *p == '^');
--- 140,146 ----
  	      return FNM_NOMATCH;
  
  	    if ((flags & FNM_PERIOD) && *n == '.' &&
! 		(n == string || ((flags & FNM_FILE_NAME) && SLASH_P(n[-1]))))
  	      return FNM_NOMATCH;
  
  	    not = (*p == '!' || *p == '^');
***************
*** 159,165 ****
  		c = *p++;
  		c = FOLD (c);
  
! 		if ((flags & FNM_FILE_NAME) && c == '/')
  		  /* [/] can never match.  */
  		  return FNM_NOMATCH;
  
--- 164,170 ----
  		c = *p++;
  		c = FOLD (c);
  
! 		if ((flags & FNM_FILE_NAME) && SLASH_P(c))
  		  /* [/] can never match.  */
  		  return FNM_NOMATCH;
  
***************
*** 215,221 ****
    if (*n == '\0')
      return 0;
  
!   if ((flags & FNM_LEADING_DIR) && *n == '/')
      /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz".  */
      return 0;
  
--- 220,226 ----
    if (*n == '\0')
      return 0;
  
!   if ((flags & FNM_LEADING_DIR) && SLASH_P(*n))
      /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz".  */
      return 0;
  
:END:PATCH:HUNKS:
# eof

-- 
Todd Whitesel
toddpw @ wrs.com

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