diff --git a/src/journal.h b/src/journal.h index f64c1d0..c29ad88 100644 --- a/src/journal.h +++ b/src/journal.h @@ -1,4 +1,5 @@ -#ifndef OMIT_BASE /* */ +#endif /* base --> */ -#ifndef OMIT_STRUCT /* */ +#endif /* generic --> */ -#ifndef OMIT_PROTO /* */ +int journal_next(struct journal_iterator *, union date32 *, const char **); +#endif /* proto --> */ + +#ifdef BASE +#undef BASE +#endif +#ifdef GENERIC +#undef GENERIC +#endif +#ifdef PROTO +#undef PROTO +#endif diff --git a/src/journal.re.c b/src/journal.re.c index 3ad769b..6f6def2 100644 --- a/src/journal.re.c +++ b/src/journal.re.c @@ -1,8 +1,7 @@ /** Reading all journal entries in yyyy/mm/dd.txt. @std GNU, C11, assumes reverse order unions. */ -#define OMIT_STRUCT -#define OMIT_PROTO +#define BASE #include "../src/journal.h" /* base */ #include /* C99 */ #include @@ -14,25 +13,21 @@ #include /* umask (POSIX) */ #include /* opendir readdir closedir */ - void date32_to_string(const union date32 d, char (*const a)[12]) { sprintf(*a, "%" PRIu32 "-%2.2" PRIu32 "-%2.2" PRIu32, d.year % 10000, d.month % 100, d.day % 100); } static int day_compare(const union date32 a, const union date32 b) { return a.u32 > b.u32; } -typedef const char *ccs; -static void day_to_string(const union date32 d, - /*const union load *const entry*/ccs *const entry, +static void day_to_string(const union date32 d, const char *const*const entry, char (*const a)[12]) { (void)entry; date32_to_string(d, a); } #define TREE_NAME day #define TREE_KEY union date32 -#define TREE_VALUE /*union load*/ /*size_t*/ /*const char **/ ccs +#define TREE_VALUE const char * #define TREE_COMPARE #define TREE_TO_STRING #include "../src/tree.h" - /* Temporary filename arrangement. */ #if INT_MAX >= 100000000000 #error int_to_string requires truncation on this compiler. @@ -48,7 +43,6 @@ static int int_cmp(const int *const a, const int *const b) static int void_int_cmp(const void *const a, const void *const b) { return int_cmp(a, b); } - /*!re2c re2c:yyfill:enable = 0; re2c:define:YYCTYPE = char; @@ -105,9 +99,7 @@ static unsigned looks_like_day(const char *const a) { */ } - -#define OMIT_BASE -#define OMIT_STRUCT +#define PROTO #include "../src/journal.h" /* Just prototypes. */ /** Dynamic memory allocation for `j` will be zero, will @@ -123,7 +115,6 @@ struct journal journal(void) { const char *const dir_journal = "journal"; struct journal j = {0}; char *intent = 0; - //union { const char **text; uintptr_t *offset; } v; DIR *dir = 0; struct dirent *de = 0; struct int_array years = int_array(), months = int_array(), @@ -207,7 +198,6 @@ struct journal journal(void) { } m = 0, int_array_clear(&months); if(chdir("..") == -1) goto catch; - /*if(*y == 1993) break;*/ } if(chdir("..") == -1 || !day_tree_bulk_finish(&j.days)) goto catch; @@ -227,8 +217,7 @@ catch: dir_journal, y ? *y : 0, m ? *m : 0, d ? *d : 0 ); if(intent) fprintf(stderr, "Explanation: %s.\n", intent); recatch: - day_tree_(&j.days); - text_(&j.backing); + journal_(&j); finally: if(dir) { if(closedir(dir)) { dir = 0; goto recatch; } dir = 0; } int_array_(&years), int_array_(&months), int_array_(&days); diff --git a/src/kjv.h b/src/kjv.h index 35ed909..3265cf6 100644 --- a/src/kjv.h +++ b/src/kjv.h @@ -1,4 +1,5 @@ -#ifndef OMIT_BASE /* */ +#endif /* base --> */ -#ifndef OMIT_VERSES /* */ +#endif /* generic --> */ -#ifndef OMIT_PROTO /* */ +#endif /* proto --> */ + +#ifdef BASE +#undef BASE +#endif +#ifdef GENERIC +#undef GENERIC +#endif +#ifdef PROTO +#undef PROTO +#endif diff --git a/src/kjv.re.c b/src/kjv.re.c index 9fb5122..f6e27fe 100644 --- a/src/kjv.re.c +++ b/src/kjv.re.c @@ -7,10 +7,9 @@ "All included Bible translations are in the public domain." @std C11 */ -#include "../src/text.h" -#define OMIT_VERSES -#define OMIT_PROTO +#define BASE #include "../src/kjv.h" /* Just the base data. */ +#include "../src/text.h" #include "../src/helper.h" #include #include @@ -144,8 +143,7 @@ scan: } -#define OMIT_BASE -#define OMIT_VERSES +#define PROTO #include "../src/kjv.h" /* Just the kjv and prototypes. */ /** Frees `kjv`. */