Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd46e643

Browse files
committed
Add Win32 path handling for / vs. \ and drive letters.
1 parent9bad936 commitd46e643

File tree

22 files changed

+147
-88
lines changed

22 files changed

+147
-88
lines changed

‎src/Makefile.global.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.160 2003/03/29 11:31:51 petere Exp $
2+
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.161 2003/04/04 20:42:11 momjian Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -338,7 +338,7 @@ endif
338338
#
339339
# substitute implementations of the C library
340340

341-
LIBOBJS = @LIBOBJS@
341+
LIBOBJS = @LIBOBJS@ path.o
342342

343343
ifneq (,$(LIBOBJS))
344344
LIBS += -lpgport

‎src/backend/commands/copy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.190 2003/03/27 16:51:27 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.191 2003/04/04 20:42:11 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -476,7 +476,7 @@ DoCopy(const CopyStmt *stmt)
476476
* Prevent write to relative path ... too easy to shoot
477477
* oneself in the foot by overwriting a database file ...
478478
*/
479-
if (filename[0]!='/')
479+
if (!is_absolute_path(filename))
480480
elog(ERROR,"Relative path not allowed for server side"
481481
" COPY command");
482482

‎src/backend/commands/dbcommands.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.111 2003/04/04 20:40:44 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.112 2003/04/04 20:42:12 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -698,9 +698,9 @@ resolve_alt_dbpath(const char *dbpath, Oid dboid)
698698
if (dbpath==NULL||dbpath[0]=='\0')
699699
returnNULL;
700700

701-
if (strchr(dbpath,'/'))
701+
if (first_path_separator(dbpath))
702702
{
703-
if (dbpath[0]!='/')
703+
if (!is_absolute_path(dbpath))
704704
elog(ERROR,"Relative paths are not allowed as database locations");
705705
#ifndefALLOW_ABSOLUTE_DBPATHS
706706
elog(ERROR,"Absolute paths are not allowed as database locations");
@@ -714,7 +714,7 @@ resolve_alt_dbpath(const char *dbpath, Oid dboid)
714714

715715
if (!var)
716716
elog(ERROR,"Postmaster environment variable '%s' not set",dbpath);
717-
if (var[0]!='/')
717+
if (!is_absolute_path(var))
718718
elog(ERROR,"Postmaster environment variable '%s' must be absolute path",dbpath);
719719
prefix=var;
720720
}

‎src/backend/storage/file/fd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.96 2003/03/27 16:51:29 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.97 2003/04/04 20:42:12 momjian Exp $
1111
*
1212
* NOTES:
1313
*
@@ -607,7 +607,7 @@ filepath(const char *filename)
607607
char*buf;
608608

609609
/* Not an absolute path name? Then fill in with database path... */
610-
if (*filename!='/')
610+
if (!is_absolute_path(filename))
611611
{
612612
buf= (char*)palloc(strlen(DatabasePath)+strlen(filename)+2);
613613
sprintf(buf,"%s/%s",DatabasePath,filename);

‎src/backend/utils/fmgr/dfmgr.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.57 2002/09/02 02:47:05 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.58 2003/04/04 20:42:12 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -271,7 +271,7 @@ expand_dynamic_library_name(const char *name)
271271

272272
AssertArg(name);
273273

274-
have_slash= (strchr(name,'/')!=NULL);
274+
have_slash= (first_path_separator(name)!=NULL);
275275

276276
if (!have_slash)
277277
{
@@ -326,7 +326,13 @@ substitute_libpath_macro(const char *name)
326326
if (name[0]!='$')
327327
returnpstrdup(name);
328328

329-
macroname_len=strcspn(name+1,"/")+1;
329+
macroname_len=strcspn(name+1,
330+
#ifndefWIN32
331+
"/"
332+
#else
333+
"/\\"
334+
#endif
335+
)+1;
330336

331337
if (strncmp(name,"$libdir",macroname_len)==0)
332338
replacement=PKGLIBDIR;
@@ -362,7 +368,7 @@ find_in_dynamic_libpath(const char *basename)
362368
size_tbaselen;
363369

364370
AssertArg(basename!=NULL);
365-
AssertArg(strchr(basename,'/')==NULL);
371+
AssertArg(first_path_separator(basename)==NULL);
366372
AssertState(Dynamic_library_path!=NULL);
367373

368374
p=Dynamic_library_path;
@@ -391,7 +397,7 @@ find_in_dynamic_libpath(const char *basename)
391397
pfree(piece);
392398

393399
/* only absolute paths */
394-
if (mangled[0]!='/')
400+
if (!is_absolute_path(mangled))
395401
elog(ERROR,"dynamic_library_path component is not absolute");
396402

397403
full=palloc(strlen(mangled)+1+baselen+1);

‎src/backend/utils/init/findbe.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.31 2002/11/02 15:54:13 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.32 2003/04/04 20:42:12 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -159,14 +159,14 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
159159
* (making sure that a relative path is made absolute before returning
160160
* it).
161161
*/
162-
if (argv0&& (p=strrchr(argv0,'/'))&&*++p)
162+
if (argv0&& (p=last_path_separator(argv0))&&*++p)
163163
{
164-
if (*argv0=='/'|| !getcwd(buf,MAXPGPATH))
164+
if (is_absolute_path(argv0)|| !getcwd(buf,MAXPGPATH))
165165
buf[0]='\0';
166166
else
167167
strcat(buf,"/");
168168
strcat(buf,argv0);
169-
p=strrchr(buf,'/');
169+
p=last_path_separator(buf);
170170
strcpy(++p,binary_name);
171171
if (ValidateBinary(buf)==0)
172172
{
@@ -194,7 +194,7 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
194194
continue;
195195
if (endp)
196196
*endp='\0';
197-
if (*startp=='/'|| !getcwd(buf,MAXPGPATH))
197+
if (is_absolute_path(startp)|| !getcwd(buf,MAXPGPATH))
198198
buf[0]='\0';
199199
else
200200
strcat(buf,"/");

‎src/backend/utils/init/miscinit.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.101 2003/03/20 04:51:44 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.102 2003/04/04 20:42:12 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -134,7 +134,7 @@ SetDataDir(const char *dir)
134134
AssertArg(dir);
135135

136136
/* If presented path is relative, convert to absolute */
137-
if (dir[0]!='/')
137+
if (!is_absolute_path(dir))
138138
{
139139
char*buf;
140140
size_tbuflen;
@@ -179,7 +179,11 @@ SetDataDir(const char *dir)
179179
* generating funny-looking paths to individual files.
180180
*/
181181
newlen=strlen(new);
182-
if (newlen>1&&new[newlen-1]=='/')
182+
if (newlen>1&&new[newlen-1]=='/'
183+
#ifdefWIN32
184+
||new[newlen-1]=='\\'
185+
#endif
186+
)
183187
new[newlen-1]='\0';
184188

185189
if (DataDir)

‎src/backend/utils/misc/database.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.55 2003/03/10 22:28:19 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.56 2003/04/04 20:42:12 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -50,10 +50,10 @@ ExpandDatabasePath(const char *dbpath)
5050
returnNULL;/* ain't gonna fit nohow */
5151

5252
/* leading path delimiter? then already absolute path */
53-
if (*dbpath=='/')
53+
if (is_absolute_path(dbpath))
5454
{
5555
#ifdefALLOW_ABSOLUTE_DBPATHS
56-
cp=strrchr(dbpath,'/');
56+
cp=last_path_separator(dbpath);
5757
len=cp-dbpath;
5858
strncpy(buf,dbpath,len);
5959
snprintf(&buf[len],MAXPGPATH-len,"/base/%s", (cp+1));
@@ -62,7 +62,7 @@ ExpandDatabasePath(const char *dbpath)
6262
#endif
6363
}
6464
/* path delimiter somewhere? then has leading environment variable */
65-
elseif ((cp=strchr(dbpath,'/'))!=NULL)
65+
elseif ((cp=first_path_separator(dbpath))!=NULL)
6666
{
6767
constchar*envvar;
6868

‎src/bin/pg_controldata/pg_controldata.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
77
* licence: BSD
88
*
9-
* $Header: /cvsroot/pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.8 2003/01/08 22:26:34 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.9 2003/04/04 20:42:12 momjian Exp $
1010
*/
1111
#include"postgres.h"
1212

@@ -82,10 +82,7 @@ main(int argc, char *argv[])
8282
textdomain("pg_controldata");
8383
#endif
8484

85-
if (!strrchr(argv[0],'/'))
86-
progname=argv[0];
87-
else
88-
progname=strrchr(argv[0],'/')+1;
85+
progname=get_progname(argv[0]);
8986

9087
if (argc>1)
9188
{

‎src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.325 2003/03/31 20:48:45 momjian Exp $
15+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.326 2003/04/04 20:42:12 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -244,10 +244,7 @@ main(int argc, char **argv)
244244

245245
dataOnly=schemaOnly=dumpData=attrNames= false;
246246

247-
if (!strrchr(argv[0],'/'))
248-
progname=argv[0];
249-
else
250-
progname=strrchr(argv[0],'/')+1;
247+
progname=get_progname(argv[0]);
251248

252249
/* Set default options based on progname */
253250
if (strcmp(progname,"pg_backup")==0)

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.16 2003/03/14 22:45:49 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.17 2003/04/04 20:42:12 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -100,10 +100,7 @@ main(int argc, char *argv[])
100100
textdomain("pg_dump");
101101
#endif
102102

103-
if (!strrchr(argv[0],'/'))
104-
progname=argv[0];
105-
else
106-
progname=strrchr(argv[0],'/')+1;
103+
progname=get_progname(argv[0]);
107104

108105
if (argc>1)
109106
{
@@ -730,7 +727,7 @@ findPgDump(const char *argv0)
730727
returnresult;
731728

732729
cmd=createPQExpBuffer();
733-
last=strrchr(argv0,'/');
730+
last=last_path_separator(argv0);
734731

735732
if (!last)
736733
appendPQExpBuffer(cmd,"pg_dump");

‎src/bin/pg_dump/pg_restore.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
*
3636
* IDENTIFICATION
37-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.44 2003/01/06 18:53:25 petere Exp $
37+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.45 2003/04/04 20:42:13 momjian Exp $
3838
*
3939
*-------------------------------------------------------------------------
4040
*/
@@ -137,10 +137,7 @@ main(int argc, char **argv)
137137

138138
opts=NewRestoreOptions();
139139

140-
if (!strrchr(argv[0],'/'))
141-
progname=argv[0];
142-
else
143-
progname=strrchr(argv[0],'/')+1;
140+
progname=get_progname(argv[0]);
144141

145142
if (argc>1)
146143
{

‎src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
26-
* $Header: /cvsroot/pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.8 2002/10/18 22:05:36 petere Exp $
26+
* $Header: /cvsroot/pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.9 2003/04/04 20:42:13 momjian Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -105,10 +105,7 @@ main(int argc, char *argv[])
105105
textdomain("pg_resetxlog");
106106
#endif
107107

108-
if (!strrchr(argv[0],'/'))
109-
progname=argv[0];
110-
else
111-
progname=strrchr(argv[0],'/')+1;
108+
progname=get_progname(argv[0]);
112109

113110
if (argc>1)
114111
{

‎src/bin/psql/prompt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.24 2003/03/20 15:39:53 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.25 2003/04/04 20:42:13 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"prompt.h"
@@ -130,7 +130,7 @@ get_prompt(promptStatus_t status)
130130
constchar*host=PQhost(pset.db);
131131

132132
/* INET socket */
133-
if (host&&host[0]&&host[0]!='/')
133+
if (host&&host[0]&&!is_absolute_path(host))
134134
{
135135
strncpy(buf,host,MAX_PROMPT_SIZE);
136136
if (*p=='m')

‎src/bin/psql/startup.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.72 2003/03/20 06:43:35 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.73 2003/04/04 20:42:13 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -110,10 +110,7 @@ main(int argc, char *argv[])
110110
textdomain("psql");
111111
#endif
112112

113-
if (!strrchr(argv[0],'/'))
114-
pset.progname=argv[0];
115-
else
116-
pset.progname=strrchr(argv[0],'/')+1;
113+
pset.progname=get_progname(argv[0]);
117114

118115
if (argc>1)
119116
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp