From 0fd15a49ef2cddad34dd86ff805218d91cbb643b Mon Sep 17 00:00:00 2001 From: James Youngman Date: Tue, 22 Feb 2005 18:57:51 +0000 Subject: [PATCH] For the %h format, don't bail out early as the format might contain something else too. --- find/pred.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/find/pred.c b/find/pred.c index 953dee74..7a168a61 100644 --- a/find/pred.c +++ b/find/pred.c @@ -635,14 +635,23 @@ pred_fprintf (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr) case 'h': /* leading directories part of path */ { char cc; - + cp = strrchr (pathname, '/'); if (cp == NULL) /* No leading directories. */ - break; - cc = *cp; - *cp = '\0'; - fprintf (fp, segment->text, pathname); - *cp = cc; + { + /* If there is no slash in the pathname, we still + * print the string because it contains characters + * other than just '%s'. + */ + fprintf (fp, segment->text, ""); + } + else + { + cc = *cp; + *cp = '\0'; + fprintf (fp, segment->text, pathname); + *cp = cc; + } break; } case 'H': /* ARGV element file was found under */