Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
d46e6438
Commit
d46e6438
authored
Apr 04, 2003
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Win32 path handling for / vs. \ and drive letters.
parent
9bad936f
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
147 additions
and
88 deletions
+147
-88
src/Makefile.global.in
src/Makefile.global.in
+2
-2
src/backend/commands/copy.c
src/backend/commands/copy.c
+2
-2
src/backend/commands/dbcommands.c
src/backend/commands/dbcommands.c
+4
-4
src/backend/storage/file/fd.c
src/backend/storage/file/fd.c
+2
-2
src/backend/utils/fmgr/dfmgr.c
src/backend/utils/fmgr/dfmgr.c
+11
-5
src/backend/utils/init/findbe.c
src/backend/utils/init/findbe.c
+5
-5
src/backend/utils/init/miscinit.c
src/backend/utils/init/miscinit.c
+7
-3
src/backend/utils/misc/database.c
src/backend/utils/misc/database.c
+4
-4
src/bin/pg_controldata/pg_controldata.c
src/bin/pg_controldata/pg_controldata.c
+2
-5
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+2
-5
src/bin/pg_dump/pg_dumpall.c
src/bin/pg_dump/pg_dumpall.c
+3
-6
src/bin/pg_dump/pg_restore.c
src/bin/pg_dump/pg_restore.c
+2
-5
src/bin/pg_resetxlog/pg_resetxlog.c
src/bin/pg_resetxlog/pg_resetxlog.c
+2
-5
src/bin/psql/prompt.c
src/bin/psql/prompt.c
+2
-2
src/bin/psql/startup.c
src/bin/psql/startup.c
+2
-5
src/bin/scripts/common.c
src/bin/scripts/common.c
+1
-14
src/bin/scripts/common.h
src/bin/scripts/common.h
+0
-1
src/include/c.h
src/include/c.h
+7
-1
src/interfaces/ecpg/ecpglib/connect.c
src/interfaces/ecpg/ecpglib/connect.c
+2
-2
src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/ecpg.c
+3
-6
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-connect.c
+4
-4
src/port/path.c
src/port/path.c
+78
-0
No files found.
src/Makefile.global.in
View file @
d46e6438
# -*-makefile-*-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.16
0 2003/03/29 11:31:51 petere
Exp $
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.16
1 2003/04/04 20:42:11 momjian
Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
...
...
@@ -338,7 +338,7 @@ endif
#
# substitute implementations of the C library
LIBOBJS
=
@LIBOBJS@
LIBOBJS
=
@LIBOBJS@
path.o
ifneq
(,$(LIBOBJS))
LIBS
+=
-lpgport
...
...
src/backend/commands/copy.c
View file @
d46e6438
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.19
0 2003/03/27 16:51:27
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.19
1 2003/04/04 20:42:11
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -476,7 +476,7 @@ DoCopy(const CopyStmt *stmt)
* Prevent write to relative path ... too easy to shoot
* oneself in the foot by overwriting a database file ...
*/
if
(
filename
[
0
]
!=
'/'
)
if
(
!
is_absolute_path
(
filename
)
)
elog
(
ERROR
,
"Relative path not allowed for server side"
" COPY command"
);
...
...
src/backend/commands/dbcommands.c
View file @
d46e6438
...
...
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.11
1 2003/04/04 20:40:44
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.11
2 2003/04/04 20:42:12
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -698,9 +698,9 @@ resolve_alt_dbpath(const char *dbpath, Oid dboid)
if
(
dbpath
==
NULL
||
dbpath
[
0
]
==
'\0'
)
return
NULL
;
if
(
strchr
(
dbpath
,
'/'
))
if
(
first_path_separator
(
dbpath
))
{
if
(
dbpath
[
0
]
!=
'/'
)
if
(
!
is_absolute_path
(
dbpath
)
)
elog
(
ERROR
,
"Relative paths are not allowed as database locations"
);
#ifndef ALLOW_ABSOLUTE_DBPATHS
elog
(
ERROR
,
"Absolute paths are not allowed as database locations"
);
...
...
@@ -714,7 +714,7 @@ resolve_alt_dbpath(const char *dbpath, Oid dboid)
if
(
!
var
)
elog
(
ERROR
,
"Postmaster environment variable '%s' not set"
,
dbpath
);
if
(
var
[
0
]
!=
'/'
)
if
(
!
is_absolute_path
(
var
)
)
elog
(
ERROR
,
"Postmaster environment variable '%s' must be absolute path"
,
dbpath
);
prefix
=
var
;
}
...
...
src/backend/storage/file/fd.c
View file @
d46e6438
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.9
6 2003/03/27 16:51:29
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.9
7 2003/04/04 20:42:12
momjian Exp $
*
* NOTES:
*
...
...
@@ -607,7 +607,7 @@ filepath(const char *filename)
char
*
buf
;
/* Not an absolute path name? Then fill in with database path... */
if
(
*
filename
!=
'/'
)
if
(
!
is_absolute_path
(
filename
)
)
{
buf
=
(
char
*
)
palloc
(
strlen
(
DatabasePath
)
+
strlen
(
filename
)
+
2
);
sprintf
(
buf
,
"%s/%s"
,
DatabasePath
,
filename
);
...
...
src/backend/utils/fmgr/dfmgr.c
View file @
d46e6438
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.5
7 2002/09/02 02:47:05
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.5
8 2003/04/04 20:42:12
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -271,7 +271,7 @@ expand_dynamic_library_name(const char *name)
AssertArg
(
name
);
have_slash
=
(
strchr
(
name
,
'/'
)
!=
NULL
);
have_slash
=
(
first_path_separator
(
name
)
!=
NULL
);
if
(
!
have_slash
)
{
...
...
@@ -326,7 +326,13 @@ substitute_libpath_macro(const char *name)
if
(
name
[
0
]
!=
'$'
)
return
pstrdup
(
name
);
macroname_len
=
strcspn
(
name
+
1
,
"/"
)
+
1
;
macroname_len
=
strcspn
(
name
+
1
,
#ifndef WIN32
"/"
#else
"/
\\
"
#endif
)
+
1
;
if
(
strncmp
(
name
,
"$libdir"
,
macroname_len
)
==
0
)
replacement
=
PKGLIBDIR
;
...
...
@@ -362,7 +368,7 @@ find_in_dynamic_libpath(const char *basename)
size_t
baselen
;
AssertArg
(
basename
!=
NULL
);
AssertArg
(
strchr
(
basename
,
'/'
)
==
NULL
);
AssertArg
(
first_path_separator
(
basename
)
==
NULL
);
AssertState
(
Dynamic_library_path
!=
NULL
);
p
=
Dynamic_library_path
;
...
...
@@ -391,7 +397,7 @@ find_in_dynamic_libpath(const char *basename)
pfree
(
piece
);
/* only absolute paths */
if
(
mangled
[
0
]
!=
'/'
)
if
(
!
is_absolute_path
(
mangled
)
)
elog
(
ERROR
,
"dynamic_library_path component is not absolute"
);
full
=
palloc
(
strlen
(
mangled
)
+
1
+
baselen
+
1
);
...
...
src/backend/utils/init/findbe.c
View file @
d46e6438
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.3
1 2002/11/02 15:54:13 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.3
2 2003/04/04 20:42:12 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -159,14 +159,14 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
* (making sure that a relative path is made absolute before returning
* it).
*/
if
(
argv0
&&
(
p
=
strrchr
(
argv0
,
'/'
))
&&
*++
p
)
if
(
argv0
&&
(
p
=
last_path_separator
(
argv0
))
&&
*++
p
)
{
if
(
*
argv0
==
'/'
||
!
getcwd
(
buf
,
MAXPGPATH
))
if
(
is_absolute_path
(
argv0
)
||
!
getcwd
(
buf
,
MAXPGPATH
))
buf
[
0
]
=
'\0'
;
else
strcat
(
buf
,
"/"
);
strcat
(
buf
,
argv0
);
p
=
strrchr
(
buf
,
'/'
);
p
=
last_path_separator
(
buf
);
strcpy
(
++
p
,
binary_name
);
if
(
ValidateBinary
(
buf
)
==
0
)
{
...
...
@@ -194,7 +194,7 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
continue
;
if
(
endp
)
*
endp
=
'\0'
;
if
(
*
startp
==
'/'
||
!
getcwd
(
buf
,
MAXPGPATH
))
if
(
is_absolute_path
(
startp
)
||
!
getcwd
(
buf
,
MAXPGPATH
))
buf
[
0
]
=
'\0'
;
else
strcat
(
buf
,
"/"
);
...
...
src/backend/utils/init/miscinit.c
View file @
d46e6438
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.10
1 2003/03/20 04:51:44
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.10
2 2003/04/04 20:42:12
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -134,7 +134,7 @@ SetDataDir(const char *dir)
AssertArg
(
dir
);
/* If presented path is relative, convert to absolute */
if
(
dir
[
0
]
!=
'/'
)
if
(
!
is_absolute_path
(
dir
)
)
{
char
*
buf
;
size_t
buflen
;
...
...
@@ -179,7 +179,11 @@ SetDataDir(const char *dir)
* generating funny-looking paths to individual files.
*/
newlen
=
strlen
(
new
);
if
(
newlen
>
1
&&
new
[
newlen
-
1
]
==
'/'
)
if
(
newlen
>
1
&&
new
[
newlen
-
1
]
==
'/'
#ifdef WIN32
||
new
[
newlen
-
1
]
==
'\\'
#endif
)
new
[
newlen
-
1
]
=
'\0'
;
if
(
DataDir
)
...
...
src/backend/utils/misc/database.c
View file @
d46e6438
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.5
5 2003/03/10 22:28:19 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.5
6 2003/04/04 20:42:12 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -50,10 +50,10 @@ ExpandDatabasePath(const char *dbpath)
return
NULL
;
/* ain't gonna fit nohow */
/* leading path delimiter? then already absolute path */
if
(
*
dbpath
==
'/'
)
if
(
is_absolute_path
(
dbpath
)
)
{
#ifdef ALLOW_ABSOLUTE_DBPATHS
cp
=
strrchr
(
dbpath
,
'/'
);
cp
=
last_path_separator
(
dbpath
);
len
=
cp
-
dbpath
;
strncpy
(
buf
,
dbpath
,
len
);
snprintf
(
&
buf
[
len
],
MAXPGPATH
-
len
,
"/base/%s"
,
(
cp
+
1
));
...
...
@@ -62,7 +62,7 @@ ExpandDatabasePath(const char *dbpath)
#endif
}
/* path delimiter somewhere? then has leading environment variable */
else
if
((
cp
=
strchr
(
dbpath
,
'/'
))
!=
NULL
)
else
if
((
cp
=
first_path_separator
(
dbpath
))
!=
NULL
)
{
const
char
*
envvar
;
...
...
src/bin/pg_controldata/pg_controldata.c
View file @
d46e6438
...
...
@@ -6,7 +6,7 @@
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
* licence: BSD
*
* $Header: /cvsroot/pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.
8 2003/01/08 22:26:34
momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.
9 2003/04/04 20:42:12
momjian Exp $
*/
#include "postgres.h"
...
...
@@ -82,10 +82,7 @@ main(int argc, char *argv[])
textdomain
(
"pg_controldata"
);
#endif
if
(
!
strrchr
(
argv
[
0
],
'/'
))
progname
=
argv
[
0
];
else
progname
=
strrchr
(
argv
[
0
],
'/'
)
+
1
;
progname
=
get_progname
(
argv
[
0
]);
if
(
argc
>
1
)
{
...
...
src/bin/pg_dump/pg_dump.c
View file @
d46e6438
...
...
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.32
5 2003/03/31 20:48:45
momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.32
6 2003/04/04 20:42:12
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -244,10 +244,7 @@ main(int argc, char **argv)
dataOnly
=
schemaOnly
=
dumpData
=
attrNames
=
false
;
if
(
!
strrchr
(
argv
[
0
],
'/'
))
progname
=
argv
[
0
];
else
progname
=
strrchr
(
argv
[
0
],
'/'
)
+
1
;
progname
=
get_progname
(
argv
[
0
]);
/* Set default options based on progname */
if
(
strcmp
(
progname
,
"pg_backup"
)
==
0
)
...
...
src/bin/pg_dump/pg_dumpall.c
View file @
d46e6438
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.1
6 2003/03/14 22:45:49 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.1
7 2003/04/04 20:42:12 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -100,10 +100,7 @@ main(int argc, char *argv[])
textdomain
(
"pg_dump"
);
#endif
if
(
!
strrchr
(
argv
[
0
],
'/'
))
progname
=
argv
[
0
];
else
progname
=
strrchr
(
argv
[
0
],
'/'
)
+
1
;
progname
=
get_progname
(
argv
[
0
]);
if
(
argc
>
1
)
{
...
...
@@ -730,7 +727,7 @@ findPgDump(const char *argv0)
return
result
;
cmd
=
createPQExpBuffer
();
last
=
strrchr
(
argv0
,
'/'
);
last
=
last_path_separator
(
argv0
);
if
(
!
last
)
appendPQExpBuffer
(
cmd
,
"pg_dump"
);
...
...
src/bin/pg_dump/pg_restore.c
View file @
d46e6438
...
...
@@ -34,7 +34,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.4
4 2003/01/06 18:53:25 petere
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.4
5 2003/04/04 20:42:13 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -137,10 +137,7 @@ main(int argc, char **argv)
opts
=
NewRestoreOptions
();
if
(
!
strrchr
(
argv
[
0
],
'/'
))
progname
=
argv
[
0
];
else
progname
=
strrchr
(
argv
[
0
],
'/'
)
+
1
;
progname
=
get_progname
(
argv
[
0
]);
if
(
argc
>
1
)
{
...
...
src/bin/pg_resetxlog/pg_resetxlog.c
View file @
d46e6438
...
...
@@ -23,7 +23,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.
8 2002/10/18 22:05:36 petere
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.
9 2003/04/04 20:42:13 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -105,10 +105,7 @@ main(int argc, char *argv[])
textdomain
(
"pg_resetxlog"
);
#endif
if
(
!
strrchr
(
argv
[
0
],
'/'
))
progname
=
argv
[
0
];
else
progname
=
strrchr
(
argv
[
0
],
'/'
)
+
1
;
progname
=
get_progname
(
argv
[
0
]);
if
(
argc
>
1
)
{
...
...
src/bin/psql/prompt.c
View file @
d46e6438
...
...
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.2
4 2003/03/20 15:39:5
3 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.2
5 2003/04/04 20:42:1
3 momjian Exp $
*/
#include "postgres_fe.h"
#include "prompt.h"
...
...
@@ -130,7 +130,7 @@ get_prompt(promptStatus_t status)
const
char
*
host
=
PQhost
(
pset
.
db
);
/* INET socket */
if
(
host
&&
host
[
0
]
&&
host
[
0
]
!=
'/'
)
if
(
host
&&
host
[
0
]
&&
!
is_absolute_path
(
host
)
)
{
strncpy
(
buf
,
host
,
MAX_PROMPT_SIZE
);
if
(
*
p
==
'm'
)
...
...
src/bin/psql/startup.c
View file @
d46e6438
...
...
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.7
2 2003/03/20 06:43:35
momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.7
3 2003/04/04 20:42:13
momjian Exp $
*/
#include "postgres_fe.h"
...
...
@@ -110,10 +110,7 @@ main(int argc, char *argv[])
textdomain
(
"psql"
);
#endif
if
(
!
strrchr
(
argv
[
0
],
'/'
))
pset
.
progname
=
argv
[
0
];
else
pset
.
progname
=
strrchr
(
argv
[
0
],
'/'
)
+
1
;
pset
.
progname
=
get_progname
(
argv
[
0
]);
if
(
argc
>
1
)
{
...
...
src/bin/scripts/common.c
View file @
d46e6438
...
...
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/bin/scripts/common.c,v 1.
1 2003/03/18 22:19:46 petere
Exp $
* $Header: /cvsroot/pgsql/src/bin/scripts/common.c,v 1.
2 2003/04/04 20:42:13 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -35,19 +35,6 @@ get_user_name(const char *progname)
}
/*
* Extracts the actual name of the program as called.
*/
char
*
get_progname
(
char
*
argv0
)
{
if
(
!
strrchr
(
argv0
,
'/'
))
return
argv0
;
else
return
strrchr
(
argv0
,
'/'
)
+
1
;
}
/*
* Initialized NLS if enabled.
*/
...
...
src/bin/scripts/common.h
View file @
d46e6438
...
...
@@ -16,7 +16,6 @@ int optreset;
#endif
const
char
*
get_user_name
(
const
char
*
progname
);
char
*
get_progname
(
char
*
argv0
);
#define _(x) gettext((x))
void
init_nls
(
void
);
...
...
src/include/c.h
View file @
d46e6438
...
...
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: c.h,v 1.13
5 2003/01/09 18:00:24 tgl
Exp $
* $Id: c.h,v 1.13
6 2003/04/04 20:42:13 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -692,6 +692,12 @@ typedef NameData *Name;
#include <unistd.h>
#endif
/* Portable path handling for Unix/Win32 */
bool
is_absolute_path
(
const
char
*
filename
);
char
*
first_path_separator
(
const
char
*
filename
);
char
*
last_path_separator
(
const
char
*
filename
);
char
*
get_progname
(
char
*
argv0
);
#if defined(bsdi) || defined(netbsd)
int
fseeko
(
FILE
*
stream
,
off_t
offset
,
int
whence
);
off_t
ftello
(
FILE
*
stream
);
...
...
src/interfaces/ecpg/ecpglib/connect.c
View file @
d46e6438
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.
1 2003/03/16 10:42:53 meskes
Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.
2 2003/04/04 20:42:13 momjian
Exp $ */
#include "postgres_fe.h"
...
...
@@ -326,7 +326,7 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
*
tmp
=
'\0'
;
}
tmp
=
strrchr
(
dbname
+
offset
,
'/'
);
tmp
=
last_path_separator
(
dbname
+
offset
);
if
(
tmp
!=
NULL
)
/* database name given */
{
realname
=
strdup
(
tmp
+
1
);
...
...
src/interfaces/ecpg/preproc/ecpg.c
View file @
d46e6438
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.6
4 2003/03/27 14:29:17 meskes
Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.6
5 2003/04/04 20:42:13 momjian
Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
...
...
@@ -105,10 +105,7 @@ main(int argc, char *const argv[])
struct
_include_path
*
ip
;
char
*
progname
;
if
(
!
strrchr
(
argv
[
0
],
'/'
))
progname
=
argv
[
0
];
else
progname
=
strrchr
(
argv
[
0
],
'/'
)
+
1
;
progname
=
get_progname
(
argv
[
0
]);
if
(
argc
>
1
)
{
...
...
@@ -213,7 +210,7 @@ main(int argc, char *const argv[])
strcpy
(
input_filename
,
argv
[
fnr
]);
/* take care of relative paths */
ptr2ext
=
strrchr
(
input_filename
,
'/'
);
ptr2ext
=
last_path_separator
(
input_filename
);
ptr2ext
=
(
ptr2ext
?
strrchr
(
ptr2ext
,
'.'
)
:
strrchr
(
input_filename
,
'.'
));
/* no extension? */
...
...
src/interfaces/libpq/fe-connect.c
View file @
d46e6438
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.23
0 2003/04/02 00:49:28 tgl
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.23
1 2003/04/04 20:42:13 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -330,7 +330,7 @@ PQconnectStart(const char *conninfo)
/*
* Allow unix socket specification in the host name
*/
if
(
conn
->
pghost
&&
conn
->
pghost
[
0
]
==
'/'
)
if
(
conn
->
pghost
&&
is_absolute_path
(
conn
->
pghost
)
)
{
if
(
conn
->
pgunixsocket
)
free
(
conn
->
pgunixsocket
);
...
...
@@ -449,7 +449,7 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
* We don't allow unix socket path as a function parameter. This
* allows unix socket specification in the host name.
*/
if
(
conn
->
pghost
&&
conn
->
pghost
[
0
]
==
'/'
)
if
(
conn
->
pghost
&&
is_absolute_path
(
conn
->
pghost
)
)
{
if
(
conn
->
pgunixsocket
)
free
(
conn
->
pgunixsocket
);
...
...
@@ -604,7 +604,7 @@ update_db_info(PGconn *conn)
*
tmp
=
'\0'
;
}
tmp
=
strrchr
(
conn
->
dbName
+
offset
,
'/'
);
tmp
=
last_path_separator
(
conn
->
dbName
+
offset
);
if
(
tmp
!=
NULL
)
/* database name given */
{
if
(
conn
->
dbName
)
...
...
src/port/path.c
0 → 100644
View file @
d46e6438
/* $Id: path.c,v 1.1 2003/04/04 20:42:13 momjian Exp $ */
#include "c.h"
#include <ctype.h>
/*
* is_absolute_path
*/
bool
is_absolute_path
(
const
char
*
filename
)
{
return
filename
[
0
]
==
'/'
#ifdef WIN32
/* WIN32 paths can either have forward or backward slashes */
||
filename
[
0
]
==
'\\'
||
(
isalpha
(
filename
[
0
])
&&
filename
[
1
]
==
':'
&&
(
filename
[
2
]
==
'\\'
||
filename
[
2
]
==
'/'
))
#endif
;
}
/*
* first_path_separator
*/
char
*
first_path_separator
(
const
char
*
filename
)
{
#ifndef WIN32
return
strchr
(
filename
,
'/'
);
#else
char
*
slash
,
*
bslash
;
/* How should we handle "C:file.c"? */
slash
=
strchr
(
filename
,
'/'
);
bslash
=
strchr
(
filename
,
'\\'
);
if
(
slash
==
NULL
)
return
bslash
;
else
if
(
bslash
==
NULL
)
return
slash
;
else
return
(
slash
<
bslash
)
?
slash
:
bslash
;
#endif
}
/*
* last_path_separator
*/
char
*
last_path_separator
(
const
char
*
filename
)
{
#ifndef WIN32
return
strrchr
(
filename
,
'/'
);
#else
char
*
slash
,
*
bslash
;
/* How should we handle "C:file.c"? */
slash
=
strrchr
(
filename
,
'/'
);
bslash
=
strrchr
(
filename
,
'\\'
);
if
(
slash
==
NULL
)
return
bslash
;
else
if
(
bslash
==
NULL
)
return
slash
;
else
return
(
slash
>
bslash
)
?
slash
:
bslash
;
#endif
}
/*
* Extracts the actual name of the program as called.
*/
char
*
get_progname
(
char
*
argv0
)
{
if
(
!
last_path_separator
(
argv0
))
return
argv0
;
else
return
last_path_separator
(
argv0
)
+
1
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment