From 512d44cf2f60013d8dbbfb31e23a83ec2bedfde9 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Wed, 12 Sep 2018 22:28:11 -0700 Subject: various display changes --- journal.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'journal.c') diff --git a/journal.c b/journal.c index 4a07261..7feae8b 100644 --- a/journal.c +++ b/journal.c @@ -10,7 +10,8 @@ static char *entries[MAX_ENTRIES]; static int num_entries; -static void load_entries() { +static void load_entries() +{ DIR *d = opendir(ENTRY_DIR); if (!d) exit(1); @@ -28,7 +29,8 @@ static void load_entries() { closedir(d); } -static void print_entry(char *entry) { +static void print_entry(char *entry) +{ size_t len = strlen(entry) + 1; char *path = malloc(sizeof(ENTRY_DIR) + len); memcpy(path, ENTRY_DIR"/", sizeof(ENTRY_DIR)); @@ -60,11 +62,13 @@ static void print_entry(char *entry) { printf("

\n"); } -static int entry_cmp(const void *a, const void *b) { +static int entry_cmp(const void *a, const void *b) +{ return atoi(*(const char **)b) - atoi(*(const char **)a); } -int main() { +int main() +{ load_entries(); qsort(entries, num_entries, sizeof(char *), entry_cmp); @@ -73,12 +77,12 @@ int main() { "\n" "\n" "\n" - "\n" + "\n" + "\n" "\n" "david's journal\n" "\n" "\n" - "
\n" "

david's journal

\n"); for (int i = 0; i < num_entries; ++i) { @@ -87,7 +91,6 @@ int main() { } printf( - "
\n" "\n" "\n"); -- cgit v1.2.3-70-g09d2