From: Clemens Buchacher Date: Fri, 19 Nov 2010 20:41:59 GMT Subject: Re: [PATCH] get_cwd_relative(): do not misinterpret root path Message-ID: <20101119204159.GA28622@localhost> In-Reply-To: <1290158239-12138-1-git-send-email-pclouds@gmail.com> 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