Re: Data directory with trailing [back]slash

Andrew Dunstan <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.win32,gmane.comp.db.postgresql.devel.patches
Message-ID <[email protected]>

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
canon.patch (text/x-patch, 1 KB)
Index: src/port/path.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/port/path.c,v
retrieving revision 1.20
diff -c -r1.20 path.c
*** src/port/path.c	11 Jun 2004 17:09:13 -0000	1.20
--- src/port/path.c	21 Jun 2004 00:19:27 -0000
***************
*** 115,121 ****
--- 115,144 ----
  		if (*p == '\\')
  			*p = '/';
  	}
+ 
+     /* skip network and drive specifiers for win32 */
+     if (strlen(path) >= 2)
+     {
+         if (path[0] == '/' && path[1] == '/')
+         {
+             /* network drive */
+             path = strstr(path + 2, "/");
+             if (path == NULL)
+                 return;
+         }
+         else if (path[1] == ':' &&
+                  ((path[0] >= 'a' && path[0] <= 'z') ||
+                   (path[0] >= 'A' && path[0] <= 'Z')))
+         {
+             /* local drive */
+             path += 2;
+         }
+     }
+ 
  #endif
+ 
+     if (path[0] == '/')            /* don't trim leading '/'. */
+         ++path;
  
  	trim_trailing_separator(path);
  }
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.