From 559a1b012a45fd37faad444050e1de733bbf109f Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 10 Jun 2024 00:56:26 -0400 Subject: [PATCH] Minor cleanups --- bb.c | 12 +++++++----- utils.h | 12 ++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/bb.c b/bb.c index 3919ded..7502db1 100644 --- a/bb.c +++ b/bb.c @@ -37,6 +37,8 @@ #define SCROLLOFF MIN(5, (winsize.ws_row-4)/2) #define ONSCREEN (winsize.ws_row - 3) +#define LOG(...) do { FILE *f = fopen("log.txt", "a"); fprintf(f, __VA_ARGS__); fclose(f); } while (0) + // Functions void bb_browse(bb_t *bb, int argc, char *argv[]); static void check_cmdfile(bb_t *bb); @@ -279,9 +281,9 @@ static int compare_files(const void *v1, const void *v2) } case COL_PERM: COMPARE((e1->info.st_mode & 0x3FF), (e2->info.st_mode & 0x3FF)); break; case COL_SIZE: COMPARE(e1->info.st_size, e2->info.st_size); break; - case COL_MTIME: COMPARE_TIME(mtime(e1->info), mtime(e2->info)); break; - case COL_CTIME: COMPARE_TIME(ctime(e1->info), ctime(e2->info)); break; - case COL_ATIME: COMPARE_TIME(atime(e1->info), atime(e2->info)); break; + case COL_MTIME: COMPARE_TIME(get_mtime(e1->info), get_mtime(e2->info)); break; + case COL_CTIME: COMPARE_TIME(get_ctime(e1->info), get_ctime(e2->info)); break; + case COL_ATIME: COMPARE_TIME(get_atime(e1->info), get_atime(e2->info)); break; case COL_RANDOM: COMPARE(e2->shufflepos, e1->shufflepos); break; default: break; } @@ -1007,8 +1009,8 @@ static void set_sort(bb_t *bb, const char *sort) char sortbuf[MAX_SORT+1]; strncpy(sortbuf, sort, MAX_SORT); for (char *s = sortbuf; s[0] && s[1]; s += 2) { - char *found; - if ((found = strchr(bb->sort, s[1]))) { + char *found = strchr(bb->sort, s[1]); + if (found) { if (*s == '~') *s = found[-1] == '+' && found == &bb->sort[1] ? '-' : '+'; memmove(found-1, found+1, strlen(found+1)+1); diff --git a/utils.h b/utils.h index 1cb4744..719733d 100644 --- a/utils.h +++ b/utils.h @@ -20,13 +20,13 @@ // Platform-dependent time strucutre accessors: #ifdef __APPLE__ -#define mtime(s) (s).st_mtimespec -#define atime(s) (s).st_atimespec -#define ctime(s) (s).st_ctimespec +#define get_mtime(s) (s).st_mtimespec +#define get_atime(s) (s).st_atimespec +#define get_ctime(s) (s).st_ctimespec #else -#define mtime(s) (s).st_mtim -#define atime(s) (s).st_atim -#define ctime(s) (s).st_ctim +#define get_mtime(s) (s).st_mtim +#define get_atime(s) (s).st_atim +#define get_ctime(s) (s).st_ctim #endif // Entry macros