Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0fc05a

Browse files
committed
Go back to emitting path names with forward slashes on Windows.
I'm not clear on what the double-backslash idea was intended to fix, but it breaks at least mingw GNU Make. Per report from Thomas Hallgren.
1 parent 84cc9a4 commit a0fc05a

File tree

1 file changed

+10
-29
lines changed

1 file changed

+10
-29
lines changed

src/bin/pg_config/pg_config.c

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
1919
*
20-
* $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.15 2005/10/06 12:04:58 petere Exp $
20+
* $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.16 2005/10/13 17:58:44 tgl Exp $
2121
*
2222
*-------------------------------------------------------------------------
2323
*/
@@ -32,9 +32,9 @@ static char mypath[MAXPGPATH];
3232

3333
/*
3434
* This function cleans up the paths for use with either cmd.exe or Msys
35-
* on Windows. We need them to use double backslashes and filenames without
36-
* spaces (for which a short filename is the safest equivalent) eg:
37-
* C:\\Progra~1\\
35+
* on Windows. We need them to use filenames without spaces, for which a
36+
* short filename is the safest equivalent, eg:
37+
* C:/Progra~1/
3838
*
3939
* This can fail in 2 ways - if the path doesn't exist, or short names are
4040
* disabled. In the first case, don't return any path. In the second case,
@@ -45,8 +45,7 @@ static void
4545
cleanup_path(char *path)
4646
{
4747
#ifdef WIN32
48-
int x=0, y=0;
49-
char temp[MAXPGPATH];
48+
char *ptr;
5049

5150
if (GetShortPathName(path, path, MAXPGPATH - 1) == 0)
5251
{
@@ -59,31 +58,13 @@ cleanup_path(char *path)
5958
return;
6059
}
6160
}
62-
6361

64-
/* Replace '\' with '\\'. */
65-
for (x = 0; x < strlen(path); x++)
66-
{
67-
if (path[x] == '/' || path[x] == '\\')
68-
{
69-
temp[y] = '\\';
70-
y++;
71-
temp[y] = '\\';
72-
}
73-
else
74-
{
75-
temp[y] = path[x];
76-
}
77-
78-
y++;
79-
80-
/* Bail out if we're too close to MAXPGPATH */
81-
if (y >= MAXPGPATH - 2)
82-
break;
62+
/* Replace '\' with '/' */
63+
for (ptr = path; *ptr; ptr++)
64+
{
65+
if (*ptr == '\\')
66+
*ptr = '/';
8367
}
84-
temp[y] = '\0';
85-
86-
strncpy(path, temp, MAXPGPATH - 1);
8768
#endif
8869
}
8970

0 commit comments

Comments
 (0)