From 4893e147a96c816b4d8cd3a964f938216bfca7ef Mon Sep 17 00:00:00 2001 From: millert Date: Tue, 7 Oct 2003 23:37:27 +0000 Subject: Fix printing of "Only in foo" when foo is "/" (trailing slash removal was overzealous in this case). Fix tested by Hugo Villeneuve and myself. --- usr.bin/diff/diff.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'usr.bin/diff/diff.c') diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c index aef4b781234..5fa299fa73f 100644 --- a/usr.bin/diff/diff.c +++ b/usr.bin/diff/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.42 2003/09/07 22:05:30 millert Exp $ */ +/* $OpenBSD: diff.c,v 1.43 2003/10/07 23:37:27 millert Exp $ */ /* * Copyright (c) 2003 Todd C. Miller @@ -21,7 +21,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diff.c,v 1.42 2003/09/07 22:05:30 millert Exp $"; +static const char rcsid[] = "$OpenBSD: diff.c,v 1.43 2003/10/07 23:37:27 millert Exp $"; #endif /* not lint */ #include @@ -338,14 +338,20 @@ push_excludes(char *pattern) excludes_list = entry; } +void +print_only(const char *path, size_t dirlen, const char *entry) +{ + if (dirlen > 1) + dirlen--; + printf("Only in %.*s: %s\n", (int)dirlen, path, entry); +} + void print_status(int val, char *path1, char *path2, char *entry) { switch (val) { case D_ONLY: - /* must strip off the trailing '/' */ - printf("Only in %.*s: %s\n", (int)(strlen(path1) - 1), - path1, entry); + print_only(path1, strlen(path1), entry); break; case D_COMMON: printf("Common subdirectories: %s%s and %s%s\n", -- cgit v1.2.3-59-g8ed1b