On 09:40 Fri 09 Jul , Natanael Copa wrote: > fixes #2203 > https://bugs.busybox.net/show_bug.cgi?id=2203 > --- > editors/diff.c | 6 ++++++ > 1 files changed, 6 insertions(+), 0 deletions(-) > > diff --git a/editors/diff.c b/editors/diff.c > index 07594e8..e2da626 100644 > --- a/editors/diff.c > +++ b/editors/diff.c > @@ -788,9 +788,15 @@ static void diffdir(char *p[2], const char *s_start) > > memset(&list, 0, sizeof(list)); > for (i = 0; i < 2; i++) { > + char *lc; > /*list[i].s = list[i].e = 0; - memset did it */ > /*list[i].dl = NULL; */ > > + /* trim trailing / in dirs. */ > + lc = last_char_is(p[i], '/'); > + if (lc && lc != p[i]) > + *lc = '\0'; > + > /* We need to trim root directory prefix. > * Using list.len to specify its length, > * add_to_dirlist will remove it. */ > -- > 1.7.1.1 > > _______________________________________________ > busybox mailing list > [email protected] > http://lists.busybox.net/mailman/listinfo/busybox
Thanks for reporting that bug! Besides stripping only one slash, as Bernhard pointed out, the problem with this patch is that it directly modifiles the file names stored in argv, so in case the files do differ, the headers are wrong. Consider this output from gnu diff: % diff -ur diff1 diff2///// diff -ur diff1/test diff2//////test --- diff1/test 2010-07-09 12:26:55.248987189 -0300 +++ diff2//////test 2010-07-09 11:26:08.454402145 -0300 Notice the slashes are preserved in the header. The patch below should fix the issue properly, but please do test! --- Subject: [PATCH] diff: fix for trailing slashes (bugzilla #2203) Cc: [email protected] Signed-off-by: Matheus Izvekov <[email protected]> --- editors/diff.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/editors/diff.c b/editors/diff.c index 07594e8..8d91b83 100644 --- a/editors/diff.c +++ b/editors/diff.c @@ -760,9 +760,11 @@ static int FAST_FUNC add_to_dirlist(const char *filename, void *userdata, int depth UNUSED_PARAM) { struct dlist *const l = userdata; + const char *file = filename + l->len; l->dl = xrealloc_vector(l->dl, 6, l->e); - /* + 1 skips "/" after dirname */ - l->dl[l->e] = xstrdup(filename + l->len + 1); + while(*file == '/') + file++; + l->dl[l->e] = xstrdup(file); l->e++; return TRUE; } -- 1.7.1.1 _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
