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

Commit35b0a6b

Browse files
committed
Simplify code used in is_absolute_path() macro; also add comment about
'E:abc' Win32 path handling.
1 parent76129e7 commit35b0a6b

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

‎src/include/port.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,27 @@ extern void pgfnames_cleanup(char **filenames);
6868
*By making this a macro we avoid needing to include path.c in libpq.
6969
*/
7070
#ifndefWIN32
71+
#defineIS_DIR_SEP(ch)((ch) == '/')
72+
7173
#defineis_absolute_path(filename) \
7274
( \
73-
((filename)[0] == '/') \
75+
IS_DIR_SEP((filename)[0]) \
7476
)
7577
#else
78+
#defineIS_DIR_SEP(ch)((ch) == '/' || (ch) == '\\')
79+
80+
/*
81+
* On Win32, a drive letter _not_ followed by a slash, e.g. 'E:abc', is
82+
* relative to the cwd on that drive, or the drive's root directory
83+
* if that drive has no cwd. Because the path itself cannot tell us
84+
* which is the case, we have to assume the worst, i.e. that it is not
85+
* absolute; this check is done by IS_DIR_SEP(filename[2]).
86+
*/
7687
#defineis_absolute_path(filename) \
7788
( \
78-
((filename)[0] == '/') || \
79-
(filename)[0] == '\\' || \
89+
IS_DIR_SEP((filename)[0]) || \
8090
(isalpha((unsigned char) ((filename)[0])) && (filename)[1] == ':' && \
81-
((filename)[2] == '\\' || (filename)[2] == '/')) \
91+
IS_DIR_SEP((filename)[2])) \
8292
)
8393
#endif
8494

‎src/port/path.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@
3434
#include"pg_config_paths.h"
3535

3636

37-
#ifndefWIN32
38-
#defineIS_DIR_SEP(ch)((ch) == '/')
39-
#else
40-
#defineIS_DIR_SEP(ch)((ch) == '/' || (ch) == '\\')
41-
#endif
42-
4337
#ifndefWIN32
4438
#defineIS_PATH_VAR_SEP(ch) ((ch) == ':')
4539
#else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp