From fe0c0688c3cdeeadc5c37f008cf3b8481162fb4f Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Fri, 2 Aug 2019 21:41:51 -0400 Subject: only compile regex once; remove redundant return statement --- rm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'rm.c') diff --git a/rm.c b/rm.c index e54793d..6d92815 100644 --- a/rm.c +++ b/rm.c @@ -64,6 +64,7 @@ static int rm_prompt(const char *p) if (!compiled) { char *yesexpr = nl_langinfo(YESEXPR); regcomp(&yesre, yesexpr, REG_EXTENDED | REG_ICASE | REG_NOSUB); + compiled = 1; } if (regexec(&yesre, buf, 0, NULL, 0) == 0) { @@ -80,10 +81,8 @@ int rm(const char *p, const struct stat *st, int typeflag, struct FTW *f) if (st == NULL) { fprintf(stderr, "rm: %s: unknown error\n", p); retval = 1; - return 0; - } - if (S_ISDIR(st->st_mode)) { + } else if (S_ISDIR(st->st_mode)) { if (!recursive) { fprintf(stderr, "rm: %s: %s\n", p, strerror(EISDIR)); retval = 1; -- cgit v1.2.1