doesn't work, but compiles
This commit is contained in:
parent
aebeba65f7
commit
80c95adfe6
4
Makefile
4
Makefile
@ -40,7 +40,7 @@ bin/test-text: build/text.o build/test_text.o
|
|||||||
bin/test-journal: build/text.o build/journal.o build/test_journal.o
|
bin/test-journal: build/text.o build/journal.o build/test_journal.o
|
||||||
bin/test-source: build/text.o build/pair.o build/journal.o build/source.o build/test_source.o
|
bin/test-source: build/text.o build/pair.o build/journal.o build/source.o build/test_source.o
|
||||||
bin/test-kjv: build/text.o build/pair.o build/kjvcount.o build/test_kjv.o
|
bin/test-kjv: build/text.o build/pair.o build/kjvcount.o build/test_kjv.o
|
||||||
bin/kjv: build/text.o build/pair.o build/journal.o build/kjvcount.o build/kjv.o
|
bin/kjv: build/text.o build/pair.o build/journal.o build/kjvcount.o build/kjv.o build/source.o
|
||||||
bin/flight: build/text.o build/pair.o build/journal.o build/source.o build/flights.o build/flighthours.o
|
bin/flight: build/text.o build/pair.o build/journal.o build/source.o build/flights.o build/flighthours.o
|
||||||
|
|
||||||
bin/%:
|
bin/%:
|
||||||
@ -71,7 +71,7 @@ build/%.c: src/%.re.c
|
|||||||
# # https://github.com/neil-edelman/cdoc documentation
|
# # https://github.com/neil-edelman/cdoc documentation
|
||||||
# -cdoc -o $@ $<
|
# -cdoc -o $@ $<
|
||||||
|
|
||||||
.SECONDARY: build/kjv.c build/journal.c build/source.c build/scan_kjv.c build/flight.c
|
.SECONDARY: build/kjv.c build/journal.c build/source.c build/scan_kjv.c build/flight.c build/kjvcount.c
|
||||||
.PHONY: clean release test
|
.PHONY: clean release test
|
||||||
|
|
||||||
test: $(projects)
|
test: $(projects)
|
||||||
|
92
src/kjv.re.c
92
src/kjv.re.c
@ -193,8 +193,9 @@ catch:
|
|||||||
{
|
{
|
||||||
char datestr[12];
|
char datestr[12];
|
||||||
date32_to_string(date, &datestr);
|
date32_to_string(date, &datestr);
|
||||||
fprintf(stderr, "%s\n"
|
fprintf(stderr, "KJV lines: %s.\n"
|
||||||
"%s line %zu: %s.\n", buffer, datestr, line, why);
|
"%s line %zu: %s.\n",
|
||||||
|
kjvline_tree_to_string(lines), datestr, line, why);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -221,11 +222,11 @@ finally:
|
|||||||
int kjv_line_is_empty(const struct kjvline_tree *const lines)
|
int kjv_line_is_empty(const struct kjvline_tree *const lines)
|
||||||
{ return !lines || !lines->root.node; }
|
{ return !lines || !lines->root.node; }
|
||||||
|
|
||||||
const char *kjv_line_to_string(const struct kjvline_tree *const kl)
|
const char *kjv_line_to_string(const struct kjvline_tree *const lines)
|
||||||
{ return kjvline_tree_to_string(kl); }
|
{ return kjvline_tree_to_string(lines); }
|
||||||
|
|
||||||
struct kjvline_tree_iterator kjv_line_iterator(struct kjvline_tree *const kl)
|
struct kjvline_tree_iterator kjv_line_iterator(struct kjvline_tree *const lines)
|
||||||
{ return kjvline_tree_iterator(kl); }
|
{ return kjvline_tree_iterator(lines); }
|
||||||
|
|
||||||
int kjv_line_next(struct kjvline_tree_iterator *const it, union line64 *const k,
|
int kjv_line_next(struct kjvline_tree_iterator *const it, union line64 *const k,
|
||||||
const struct kjvrange **const v) {
|
const struct kjvrange **const v) {
|
||||||
@ -241,52 +242,63 @@ int kjv_line_next(struct kjvline_tree_iterator *const it, union line64 *const k,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#include "../src/source.h"
|
||||||
char citestr[12], datestr[12];
|
|
||||||
const struct source *src = source_lookup(&s, line);
|
|
||||||
assert(src); if(!src->name.a) { errno = EDOM; goto catch; }
|
|
||||||
kjvcite_to_string(cite, &citestr);
|
|
||||||
for( ; ; cite.verse++) {
|
|
||||||
if(!kjv_add(kj, cite)) return 0;
|
|
||||||
if(!verse_end || verse_end <= cite.verse) break;
|
|
||||||
}
|
|
||||||
date32_to_string(date, &datestr);
|
|
||||||
printf("%s\t%zu\t%zu\t%zu\t# ",
|
|
||||||
datestr, kj->words.verse, kj->words.set, kj->words.cumulative);
|
|
||||||
if(verse_end) {
|
|
||||||
printf("%s-%" PRIu32 "\n", citestr, verse_end);
|
|
||||||
} else {
|
|
||||||
printf("%s\n", citestr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
int success = EXIT_SUCCESS;
|
int success = EXIT_SUCCESS;
|
||||||
const char *reason = "unknown";
|
const char *reason = 0;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
struct kjvcount count = kjvcount();
|
struct kjvcount count = kjvcount();
|
||||||
if(kjvcount_is_empty(&count)) { reason = "kjv failed to load"; goto catch; }
|
fprintf(stderr, "KJV count: %s.\n", kjvcount_to_string(&count));
|
||||||
|
if(kjvcount_is_empty(&count))
|
||||||
|
{ reason = "kjv failed to load"; goto catch; }
|
||||||
|
|
||||||
struct journal j = journal();
|
struct journal jrnl = journal();
|
||||||
if(journal_is_empty(&j)) { reason = "journal failed to load"; goto catch; }
|
fprintf(stderr, "Journal: %s.\n", journal_to_string(&jrnl));
|
||||||
fprintf(stderr, "Journal: %s.\n", journal_to_string(&j));
|
if(journal_is_empty(&jrnl))
|
||||||
|
{ reason = "journal failed to load"; goto catch; }
|
||||||
|
|
||||||
struct kjvline_tree lines = kjv_line(&j);
|
struct sources srcs = sources(&jrnl);
|
||||||
if(kjv_line_is_empty(&lines)) { reason = "parsing failed"; goto catch; }
|
//fprintf(stderr, "Sources: %s.\n", sources_to_string(&srcs));
|
||||||
fprintf(stderr, "Lines: %s.\n", kjv_line_to_string(&lines));
|
if(sources_is_empty(&srcs))
|
||||||
|
{ reason = "sources failed to parse"; goto catch; }
|
||||||
|
|
||||||
struct journal_iterator it;
|
struct kjvline_tree lines = kjv_line(&jrnl);
|
||||||
union date32 k;
|
fprintf(stderr, "KJV lines: %s.\n", kjv_line_to_string(&lines));
|
||||||
const char *v;
|
if(kjv_line_is_empty(&lines))
|
||||||
|
{ reason = "KJV lines parsing failed"; goto catch; }
|
||||||
|
|
||||||
|
struct kjvline_tree_iterator it = kjv_line_iterator(&lines);
|
||||||
|
union line64 line;
|
||||||
|
const struct kjvrange *range;
|
||||||
|
|
||||||
printf("set term postscript eps enhanced\n"
|
printf("set term postscript eps enhanced\n"
|
||||||
"set output \"kjv.eps\"\n"
|
"set output \"kjv.eps\"\n"
|
||||||
"$Data <<EOD\n"
|
"$Data <<EOD\n"
|
||||||
"# date\tverse\tset\tcumulative / %zu\n", count.words.total);
|
"# date\tverse\tset\tcumulative / %zu\n", count.words.total);
|
||||||
it = journal_iterator(&j);
|
while(kjv_line_next(&it, &line, &range)) {
|
||||||
while(journal_next(&it, &k, &v)) if(!scan(k, v, &lines)) goto catch;
|
char citestr[12], datestr[12];
|
||||||
|
const struct source *src = source_lookup(&srcs, line);
|
||||||
|
if(!src || !src->name.a) { errno = EDOM; goto catch; }
|
||||||
|
kjvcite_to_string(range->start, &citestr);
|
||||||
|
#if 0
|
||||||
|
//fixme
|
||||||
|
for( ; ; cite.verse++) {
|
||||||
|
if(!kjv_add(kj, cite)) return 0;
|
||||||
|
if(!verse_end || verse_end <= cite.verse) break;
|
||||||
|
}
|
||||||
|
date32_to_string(date, &datestr);
|
||||||
|
printf("%s\t%zu\t%zu\t%zu\t# ",
|
||||||
|
datestr, kj->words.verse, kj->words.set, kj->words.cumulative);
|
||||||
|
if(verse_end) {
|
||||||
|
printf("%s-%" PRIu32 "\n", citestr, verse_end);
|
||||||
|
} else {
|
||||||
|
printf("%s\n", citestr);
|
||||||
|
}
|
||||||
|
printf("%d-%.2d-%.2d:%u-%u %s\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
printf("EOD\n"
|
printf("EOD\n"
|
||||||
"set monochrome\n"
|
"set monochrome\n"
|
||||||
"set xdata time\n"
|
"set xdata time\n"
|
||||||
@ -305,10 +317,10 @@ int main(void) {
|
|||||||
catch:
|
catch:
|
||||||
success = EXIT_FAILURE;
|
success = EXIT_FAILURE;
|
||||||
perror("journal");
|
perror("journal");
|
||||||
fprintf(stderr, "Details: %s.\n", reason);
|
if(reason) fprintf(stderr, "Details: %s.\n", reason);
|
||||||
finally:
|
finally:
|
||||||
kjv_line_(&lines);
|
kjv_line_(&lines);
|
||||||
kjvcount_(&count);
|
kjvcount_(&count);
|
||||||
journal_(&j);
|
journal_(&jrnl);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,9 @@ void kjvcount_(struct kjvcount *);
|
|||||||
struct kjvcount kjvcount(void);
|
struct kjvcount kjvcount(void);
|
||||||
int kjvcount_is_empty(const struct kjvcount *);
|
int kjvcount_is_empty(const struct kjvcount *);
|
||||||
const char *kjvcount_to_string(const struct kjvcount *);
|
const char *kjvcount_to_string(const struct kjvcount *);
|
||||||
|
|
||||||
|
|
||||||
|
/* FIXME: this should be in something else. */
|
||||||
struct kjvset_table kjv_set(void);
|
struct kjvset_table kjv_set(void);
|
||||||
void kjv_set_(struct kjvset_table *);
|
void kjv_set_(struct kjvset_table *);
|
||||||
int kjv_set_add(struct kjvset_table *const set,
|
int kjv_set_add(struct kjvset_table *const set,
|
||||||
|
@ -39,6 +39,7 @@ struct sources {
|
|||||||
struct source *sources_add(struct sources *, const union line64);
|
struct source *sources_add(struct sources *, const union line64);
|
||||||
struct sources sources(struct journal *);
|
struct sources sources(struct journal *);
|
||||||
void sources_(struct sources *);
|
void sources_(struct sources *);
|
||||||
|
int sources_is_empty(const struct sources *);
|
||||||
const char *sources_to_string(const struct sources *);
|
const char *sources_to_string(const struct sources *);
|
||||||
const struct source *source_lookup(struct sources *s, const union line64 range);
|
const struct source *source_lookup(struct sources *s, const union line64 range);
|
||||||
#endif /* proto --> */
|
#endif /* proto --> */
|
||||||
|
@ -170,6 +170,9 @@ finally:
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sources_is_empty(const struct sources *const s)
|
||||||
|
{ return !s || !s->dates.root.node; }
|
||||||
|
|
||||||
/** Lookup the last source in `range` in sources `s`. They are invalidated on
|
/** Lookup the last source in `range` in sources `s`. They are invalidated on
|
||||||
adding a source, (probably fine.) */
|
adding a source, (probably fine.) */
|
||||||
const struct source *source_lookup(struct sources *const s,
|
const struct source *source_lookup(struct sources *const s,
|
||||||
|
Loading…
Reference in New Issue
Block a user