This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [patch/libiberty] IS_ABSOLUTE_PATH to handle both DOS and POS IX p ath styles
- From: Aleksandar Ristovski <ARistovski at qnx dot com>
- To: DJ Delorie <dj at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, drow at false dot org, Ryan Mansfield <RMansfield at qnx dot com>
- Date: Fri, 4 Jan 2008 15:37:52 -0500
- Subject: RE: [patch/libiberty] IS_ABSOLUTE_PATH to handle both DOS and POS IX p ath styles
> > +#define IS_ABSOLUTE_PATH_DOS(f) (((f)[0]) && ((f)[1] == ':'))
>
> Amusingly enough, this is wrong.
I simply followed existing logic. In the code it says:
#define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\')
/* Note that IS_ABSOLUTE_PATH accepts d:foo as well, although it is
only semi-absolute. This is because the users of IS_ABSOLUTE_PATH
want to know whether to prepend the current working directory to
a file name, which should not be done with a name like d:foo. */
#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || (((f)[0]) &&
((f)[1] == ':')))
Strictly speaking it is not correct, but the macros are used to determine
whether a path can be treated as an absolute or not. To be 100% correct it
would be, as you say, tricky.
_X(f) (IS_DIR_SEPARATOR_X((f)[0]))
>
> Why X and not POSIX? The X window system doesn't define any path
> separators.
No good reason. It was shorter I guess.
Thanks,
Aleksandar