delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/04/29/22:16:16

Subject: Bug in fnsplit with fix
To: djgpp AT sun DOT soe DOT clarkson DOT edu (DJ G++ Mailing List )
Date: Fri, 29 Apr 1994 21:33:20 -0400 (EDT)
From: "Mark Potter" <potter AT rri2 DOT rri DOT com>
Reply-To: rri!potter AT vtserf DOT cc DOT vt DOT edu

I just bumped into a minor bug in fnsplit().  The current fnsplit does take
into account '/' as a possible directory division.  Example:
        In              Out
        Path            Drive   Dir       Filename   Extention
        a:\dir\fn.ext   a:      \dir\     fn         .ext
        a:/dir/fn.ext   a:      <empty>   /dir/fn    .ext

The patch to fix this wasn't too bad, almost the expected one-liner.  Diff
report to follow.
					Potter

****************************************************************************

*** fnsplit.c	Fri Apr 29 20:06:48 1994
--- original\fnsplit.c	Mon Oct  4 20:27:54 1993
***************
*** 5,16 ****
  #include <string.h>
  
- static char * max_ptr( char *p1, char *p2 )
- {
-     if ( p1 > p2 )
-         return p1;
-     else
-         return p2;
- }
- 
  int fnsplit (const char *path, char *drive, char *dir, 
  	     char *name, char *ext)
--- 5,8 ----
***************
*** 35,40 ****
        pp += 2;
      }
!   pe = max_ptr( strrchr( pp, '\\'),     /* find terminating \ */
!                 strrchr( pp, '/')  );   /* find terminating / */
    if ( pe ) 
      { 
--- 27,31 ----
        pp += 2;
      }
!   pe = strrchr( pp, '\\'); /* find terminating \ */
    if ( pe ) 
      { 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019