From: Sergey Poznyakoff Date: Fri, 14 Nov 2003 09:57:49 +0000 (+0000) Subject: (safer_name_suffix): If the input file name ends with a slash, output one should... X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=3bfdc3f8ce227a2affeef5d3180d71f675ad87df;p=chaz%2Ftar (safer_name_suffix): If the input file name ends with a slash, output one should do so as well. --- diff --git a/src/names.c b/src/names.c index 66648a0..a19afd7 100644 --- a/src/names.c +++ b/src/names.c @@ -1024,10 +1024,13 @@ safer_name_suffix (char const *file_name, bool link_target) for (p = file_name + prefix_len; *p; ) { - if (p[0] == '.' && p[1] == '.' && (ISSLASH (p[2]) || !p[2])) - prefix_len = p + 2 - file_name; - else if (p[0] == '.' && ISSLASH (p[1])) - prefix_len = p + 1 - file_name; + if (p[0] == '.') + { + if (p[1] == '.' && (ISSLASH (p[2]) || !p[2])) + prefix_len = p + 2 - file_name; + else if (ISSLASH (p[1])) + prefix_len = p + 1 - file_name; + } do { @@ -1073,7 +1076,7 @@ safer_name_suffix (char const *file_name, bool link_target) WARN ((0, 0, _(diagnostic[link_target]))); } - p = "."; + p = ISSLASH (file_name[strlen(file_name)-1]) ? "./" : "."; } return (char *) p;