]> diplodocus.org Git - nmh/commitdiff
Use HasPrefix() instead of strncmp().
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 23 Oct 2016 22:44:58 +0000 (23:44 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Mon, 24 Oct 2016 09:18:56 +0000 (10:18 +0100)
uip/rmf.c

index 4558ca3..4684e7e 100644 (file)
--- a/uip/rmf.c
+++ b/uip/rmf.c
@@ -8,6 +8,7 @@
  */
 
 #include <h/mh.h>
+#include <h/utils.h>
 
 #define RMF_SWITCHES \
     X("interactive", 0, INTRSW) \
@@ -123,7 +124,7 @@ main (int argc, char **argv)
 static int
 rmf (char *folder)
 {
-    int i, j, others;
+    int i, others;
     char *maildir;
     char cur[BUFSIZ];
     struct dirent *dp;
@@ -156,7 +157,6 @@ rmf (char *folder)
 
     (void)ext_hook("del-hook", maildir, NULL);
 
-    j = strlen(BACKUP_PREFIX);
     while ((dp = readdir (dd))) {
        switch (dp->d_name[0]) {
            case '.': 
@@ -171,7 +171,7 @@ rmf (char *folder)
                if (m_atoi (dp->d_name))
                    break;
                if (strcmp (dp->d_name, LINK) == 0
-                       || strncmp (dp->d_name, BACKUP_PREFIX, j) == 0)
+                       || HasPrefix(dp->d_name, BACKUP_PREFIX))
                    break;
 
                admonish (NULL, "file \"%s/%s\" not deleted",