Minor cleanups

This commit is contained in:
Bruce Hill 2024-06-10 00:56:26 -04:00
parent adb1578476
commit 559a1b012a
2 changed files with 13 additions and 11 deletions

12
bb.c
View File

@ -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);

12
utils.h
View File

@ -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