Re: [PATCH 2/6] Refactor git_set_argv0_path() to git_extract_argv0_path()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Samstag, 10. Januar 2009, Steffen Prohaska wrote:
> @@ -63,9 +63,19 @@ const char *system_path(const char *path)
>  	return path;
>  }
>
> -void git_set_argv0_path(const char *path)
> +const char *git_extract_argv0_path(const char *argv0)
>  {
> -	argv0_path = path;

Please insert the 'if (argv0 && *argv0)' here to simplify the call sites.
Or you could introduce this check later in 4/6 because the call site in
this patch (main() of git.c) is simpler if it keeps the check.

> +	const char *slash = argv0 + strlen(argv0);
> +
> +	while (argv0 <= slash && !is_dir_sep(*slash))
> +		slash--;
> +
> +	if (slash >= argv0) {
> +		argv0_path = xstrndup(argv0, slash - argv0);
> +		return slash + 1;
> +	}
> +
> +	return argv0;
>  }

-- Hannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux