]> err.no Git - dpkg/commitdiff
Add support for skipping boring files
authorTollef Fog Heen <tfheen@err.no>
Sun, 20 Jul 2008 17:37:03 +0000 (19:37 +0200)
committerTollef Fog Heen <tfheen@err.no>
Sun, 20 Jul 2008 17:37:03 +0000 (19:37 +0200)
src/filters.c

index e38afc021b62b56e8547d5d864c305b9c95f88cc..bbbb7f3fcc040c2ddaa43a0c640d1e3004d76452 100644 (file)
 static struct filterlist *filters = NULL;
 static struct filterlist **filtertail = &filters;
 
+static int file_is_boring(char *fn)
+{
+       char *boring_suffixes[] = { REMOVECONFFEXTS, NULL };
+       char *boring_prefixes[] = { ".", NULL };
+       char *boring_files[] = { ".swp", NULL };
+       int i;
+
+       for (i = 0; boring_prefixes[i] != NULL; i++) {
+               if (strncmp(fn, boring_prefixes[i], 
+                           strlen(boring_prefixes[i])) == 0) {
+                       return 1;
+               }
+       }
+
+       for (i = 0; boring_files[i] != NULL; i++) {
+               if (strcmp(fn, boring_files[i]) == 0) {
+                       return 1;
+               }
+       }
+
+       for (i = 0; boring_suffixes[i] != NULL; i++) {
+               if (strcmp(fn + strlen(fn) - strlen(boring_suffixes[i]),
+                          boring_suffixes[i]) == 0) {
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
 static void
 loadfilter(const char *fn)
 {
@@ -119,7 +149,7 @@ loadfilters(void)
                sprintf(file, "%s/%s", dirname, dent->d_name);
                if (stat(file, &statbuf) != 0)
                        ohshite(_("error stating file '%s'"), file);
-               if (S_ISREG(statbuf.st_mode)) {
+               if (S_ISREG(statbuf.st_mode) && !file_is_boring(file)) {
                        names[i++] = m_strdup(file);
                        if (i == names_len) {
                                names_len *= 2;