More canonicalization fixes

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>, PostgreSQL Win32 port list <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: More canonicalization fixes
Date: 2004-07-12 19:26:58
Message-ID: 200407121926.i6CJQwm02866@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers-win32 pgsql-patches

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
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Jason Sheets 2004-07-12 21:21:47 Re: PostGre and Windows XP
Previous Message Darko Prenosil 2004-07-12 16:20:10 Re: PostGre and Windows XP

Browse pgsql-patches by date

  From Date Subject
Next Message Alvaro Herrera 2004-07-12 19:35:31 Re: nested xacts: update password file
Previous Message Bruce Momjian 2004-07-12 19:19:43 Re: nested xacts: update password file