@@ -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#ifndef WIN32
71+ #define IS_DIR_SEP (ch )((ch) == '/')
72+
7173#define is_absolute_path (filename ) \
7274( \
73- ((filename)[0] == '/' ) \
75+ IS_DIR_SEP ((filename)[0]) \
7476)
7577#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+ */
7687#define is_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