Re: [PATCH] Use is_absolute_path() in diff-lib.c, lockfile.c, setup.c, trace.c
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Nov 26, 2007, 07:45 UTC
- Message-ID
- <474A7991.5010202@viscovery.net>
- In-Reply-To
- <11960297431954-git-send-email-prohaska@zib.de>
Steffen Prohaska schrieb:
> Using the helper function to test for absolute paths makes porting easier.
The patch looks good.
Show 11 quoted lines
> --- a/setup.c
> +++ b/setup.c
> @@ -59,7 +59,7 @@ const char *prefix_path(const char *prefix, int len, const char *path)
> const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
> {
> static char path[PATH_MAX];
> - if (!pfx || !*pfx || arg[0] == '/')
> + if (!pfx || !*pfx || is_absolute_path(arg))
> return arg;
> memcpy(path, pfx, pfx_len);
> strcpy(path + pfx_len, arg);This instance, however, will be reworked for Windows anyway because we must do '\\' to '/' conversion even if the path is absolute (and, hence, we cannot just return the input).
But disregarding this note, the change makes the code more readable, IMO, so I'm all for it.
-- Hannes