diff options
author | Rory Bradford <roryrjb@gmail.com> | 2022-11-13 14:17:10 +0000 |
---|---|---|
committer | Rory Bradford <roryrjb@gmail.com> | 2022-11-13 14:17:10 +0000 |
commit | 5e9d09f4d037fca7ff1316cbe91a5196eee931f5 (patch) | |
tree | f5f1b430b4fe8cc14a97e2699bee4a3905f6fcfe | |
parent | e60fb81871a771f18495c5bd15b4f07d73543144 (diff) | |
download | rf-5e9d09f4d037fca7ff1316cbe91a5196eee931f5.tar.gz |
Improve code formatting
Signed-off-by: Rory Bradford <roryrjb@gmail.com>
-rw-r--r-- | .clang-format | 1 | ||||
-rw-r--r-- | ignore.c | 8 | ||||
-rw-r--r-- | rf.c | 25 |
3 files changed, 11 insertions, 23 deletions
diff --git a/.clang-format b/.clang-format index 8af29b3..894dc89 100644 --- a/.clang-format +++ b/.clang-format @@ -6,3 +6,4 @@ IndentCaseLabels: false AlignAfterOpenBracket: DontAlign AllowAllParametersOfDeclarationOnNextLine: true ConstructorInitializerAllOnOneLineOrOnePerLine: false +ColumnLimit: 120 diff --git a/ignore.c b/ignore.c index d859d46..8bff2ce 100644 --- a/ignore.c +++ b/ignore.c @@ -6,8 +6,8 @@ #include <stdlib.h> #include <string.h> -#include "rf.h" #include "ignore.h" +#include "rf.h" static int total_size; @@ -21,8 +21,7 @@ struct ignores *init_ignores(char *path) { char line[MAX_PATH_LENGTH]; total_size = IGNORE_SIZE; - struct ignores *ignores = - (struct ignores *)calloc(sizeof(struct ignores), 1); + struct ignores *ignores = (struct ignores *)calloc(sizeof(struct ignores), 1); ignores->list = (char **)calloc(sizeof(char *), IGNORE_SIZE); ignores->size = 0; @@ -55,8 +54,7 @@ struct ignores *init_ignores(char *path) { } if (i + 1 > total_size) { - ignores->list = (char **)realloc( - ignores->list, sizeof(char *) * (total_size + IGNORE_SIZE)); + ignores->list = (char **)realloc(ignores->list, sizeof(char *) * (total_size + IGNORE_SIZE)); total_size += IGNORE_SIZE; } diff --git a/rf.c b/rf.c index 616a33a..afcfb32 100644 --- a/rf.c +++ b/rf.c @@ -80,8 +80,7 @@ static int excluded(const char *name) { } /* return 1 if breaking early (e.g. reaching limit) otherwise return 0 */ -static int recurse_find(char **patterns, int *pattern_count, - const char *dirname, struct switches *switches) { +static int recurse_find(char **patterns, int *pattern_count, const char *dirname, struct switches *switches) { DIR *dir; char path[MAXPATHLEN] = {'\0'}; @@ -114,8 +113,7 @@ static int recurse_find(char **patterns, int *pattern_count, if (entry_stat.st_mode & S_IFDIR) { if (is_child(entry->d_name) && !excluded(entry->d_name)) { - if (recurse_find( - patterns, pattern_count, full_path, switches)) { + if (recurse_find(patterns, pattern_count, full_path, switches)) { closedir(dir); return 1; }; @@ -129,15 +127,11 @@ static int recurse_find(char **patterns, int *pattern_count, char *pattern = patterns[p]; if (switches->substring) { - if (strstr( - switches->wholename ? full_path : entry->d_name, - pattern) != NULL) { + if (strstr(switches->wholename ? full_path : entry->d_name, pattern) != NULL) { matched = 1; } } else { - if (fnmatch(pattern, - switches->wholename ? full_path : entry->d_name, - 0) == 0) { + if (fnmatch(pattern, switches->wholename ? full_path : entry->d_name) == 0) { matched = 1; } } @@ -157,8 +151,7 @@ static int recurse_find(char **patterns, int *pattern_count, printf("%s\n", full_path); } - if (switches->limit > 0 && - ++switches->count == switches->limit) { + if (switches->limit > 0 && ++switches->count == switches->limit) { closedir(dir); return 1; } @@ -236,12 +229,8 @@ int main(int argc, char **argv) { char local_ignore_path[strlen(cwd) + strlen(".rfignore") + 1]; const char *pattern = "%s/%s"; - snprintf(global_ignore_path, - (strlen(pattern) + strlen(home) + strlen(RFIGNORE)), pattern, home, - RFIGNORE); - snprintf(local_ignore_path, - (strlen(pattern) + strlen(cwd) + strlen(RFIGNORE)), pattern, cwd, - RFIGNORE); + snprintf(global_ignore_path, (strlen(pattern) + strlen(home) + strlen(RFIGNORE)), pattern, home, RFIGNORE); + snprintf(local_ignore_path, (strlen(pattern) + strlen(cwd) + strlen(RFIGNORE)), pattern, cwd, RFIGNORE); global_ignores = init_ignores(global_ignore_path); local_ignores = init_ignores(local_ignore_path); |