Subject: Re: [PATCH] get_cwd_relative(): do not misinterpret root path

From: Clemens Buchacher <[email-masked]>
Date: Fri, 19 Nov 2010 21:41:59 +0100

Hi Duy,

Thanks for looking into this.

On Fri, Nov 19, 2010 at 04:17:19PM +0700, Nguyễn Thái Ngọc Duy wrote:
> 
> @@ -965,6 +965,12 @@ char *get_relative_cwd(char *buffer, int size, const char *dir)
>  	case '/':
>  		return cwd + 1;
>  	default:
> +		/*
> +		 * dir can end with a path separator when it's root
> +		 * directory. Return proper prefix in that case.
> +		 */
> +		if (is_dir_sep(dir[-1]))
> +			return cwd;
>  		return NULL;
>  	}
>  }

make_absolute_path() already rewrites dir to contain slashes only.
I think it is confusing to use is_dir_sep() here, when we only
check for / above.

Otherwise, the patch looks good to me.

Clemens