@@ -68,17 +68,27 @@ extern void pgfnames_cleanup(char **filenames);
68
68
*By making this a macro we avoid needing to include path.c in libpq.
69
69
*/
70
70
#ifndef WIN32
71
+ #define IS_DIR_SEP (ch )((ch) == '/')
72
+
71
73
#define is_absolute_path (filename ) \
72
74
( \
73
- ((filename)[0] == '/' ) \
75
+ IS_DIR_SEP ((filename)[0]) \
74
76
)
75
77
#else
78
+ #define IS_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
+ */
76
87
#define is_absolute_path (filename ) \
77
88
( \
78
- ((filename)[0] == '/') || \
79
- (filename)[0] == '\\' || \
89
+ IS_DIR_SEP((filename)[0]) || \
80
90
(isalpha((unsigned char) ((filename)[0])) && (filename)[1] == ':' && \
81
- ((filename)[2] == '\\' || (filename)[2] == '/' )) \
91
+ IS_DIR_SEP ((filename)[2])) \
82
92
)
83
93
#endif
84
94