From 6ac3f5124fc9fe8fa54e13eef724f0b1b0bab4fd Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Sun, 20 Jul 2008 19:37:03 +0200 Subject: [PATCH] Add support for skipping boring files --- src/filters.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/filters.c b/src/filters.c index e38afc02..bbbb7f3f 100644 --- a/src/filters.c +++ b/src/filters.c @@ -40,6 +40,36 @@ 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; -- 2.39.5