More canonicalization fixes

Bruce Momjian <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.patches,gmane.comp.db.postgresql.devel.win32
Message-ID <[email protected]>
I just applied this new version of canonicalize_path():
	
	/*
	 * Make all paths look like Unix
	 */
	void
	canonicalize_path(char *path)
	{
	#ifdef WIN32
	    /*
	     * The Windows command processor will accept suitably quoted paths
	     * with forward slashes, but barfs badly with mixed forward and back
	     * slashes.
	     */
	    char       *p;
	
	    for (p = path; *p; p++)
	    {
	        if (*p == '\\')
	            *p = '/';
	    }

	    /*  In Win32, if you do:
	     *      prog.exe "a b" "\c\d\"
	     *  the system will pass \c\d" as argv[2].
	     */
	    if (p > path && *(p-1) == '"')
	        *(p-1) = '/';
	#endif
	
	    /*
	     *  Removing the trailing slash on a path means we never get
	     *  ugly double slashes.  Don't remove a leading slash, though.
	     *  Also, Win32 can't stat() a directory with a trailing slash.
	     */
	    trim_trailing_separator(path);
	}

The new thing Magnus found was this in Win32:

	prog.exe "a b" "\c\d\"

returns \c\d" as argv[2]

Quite amazing. The fix on Win32 is to convert a trailing double-quote to
a slash.

-- 
  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 8: explain analyze is your friend
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.