Re: [pgsql-hackers-win32] Data directory with trailing [back]slash

Bruce Momjian <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.patches,gmane.comp.db.postgresql.devel.win32
Message-ID <[email protected]>
OK, I have fixed the problem.  While your patch got close, it is best to
fix the problem in trim_trailing_separator() rather than above.

Tom already fixed the Unix case by preventing a path of '/' from being
stripped.  This patch prevents c:/ and //network/ from being stripped
too.  (Tom already mentioned Win32 would need work.)

---------------------------------------------------------------------------

Andrew Dunstan wrote:
> 
> 
> Tom Lane wrote:
> 
> >"Magnus Hagander" <[email protected]> writes:
> >  
> >
> >>It's not possible to start the postmaster on win32 with:
> >>postmaster -D d:\pgdata\
> >>or
> >>postmaster -D d:/pgdata/
> >>    
> >>
> >
> >Sounds like canonicalize_path() needs to be applied a bit sooner than
> >it is.
> >
> >BTW I think canonicalize_path() is a few bricks shy of a load yet:
> >I'm not sure it works well with Windows drive-letters, and it definitely
> >will strip significant slashes when given input like '/' or 'C:\'.
> >Feel free to fix those problems while at it...
> >  
> >
> 
> Or use the attached patch, which I think does it right.
> 
> cheers
> 
> andrew


> 
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  [email protected]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org
/bjm/diff (text/plain, 1.1 KB)
Index: src/port/path.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/path.c,v
retrieving revision 1.21
diff -c -c -r1.21 path.c
*** src/port/path.c	10 Jul 2004 22:58:42 -0000	1.21
--- src/port/path.c	11 Jul 2004 02:50:49 -0000
***************
*** 389,395 ****
  trim_trailing_separator(char *path)
  {
  	char *p = path + strlen(path);
! 	
  	/* trim off trailing slashes */
  	if (p > path)
  		for (p--; p > path && IS_DIR_SEP(*p); p--)
--- 389,414 ----
  trim_trailing_separator(char *path)
  {
  	char *p = path + strlen(path);
! 
! #ifdef WIN32
!     /* Skip over network and drive specifiers for win32 */
!     if (strlen(path) >= 2)
!     {
!         if (IS_DIR_SEP(path[0]) && IS_DIR_SEP(path[1]))
!         {
!         	path += 2;
! 			while (*path && !IS_DIR_SEP(*path))
! 				path++;
! 		}
!         else if (isalpha(path[0]) && path[1] == ':')
!         {
!             path++;
! 	        if (IS_DIR_SEP(path[1]))
!     	    	path++;
!     	}
!     }
! #endif
! 
  	/* trim off trailing slashes */
  	if (p > path)
  		for (p--; p > path && IS_DIR_SEP(*p); p--)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.