diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-08-02 21:41:51 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-08-02 21:41:51 -0400 |
commit | fe0c0688c3cdeeadc5c37f008cf3b8481162fb4f (patch) | |
tree | fa27b2e77827c1ba792a7f4e5f86f637d8dd398e | |
parent | 25965a249435a3fda795422cc61caf161580d441 (diff) |
only compile regex once; remove redundant return statement
-rw-r--r-- | rm.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -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; |