Compare commits

...

4 Commits
file ... master

5 changed files with 58 additions and 2 deletions

View File

@ -1 +1 @@
../../journal/
../../../Documents/journal/

View File

@ -46,6 +46,10 @@ int main(void) {
}
showhelp = 0;
intent = "interesting";
perror("errno");
if(errno) goto catch;
intent = "journal";
jrnl = journal();
fprintf(stderr, "Journal: %s.\n", journal_to_string(&jrnl));
@ -64,6 +68,10 @@ int main(void) {
if(!freopen(intent, "w", stdout)) goto catch;
scan_score_graph(&scn);
intent = "labs.csv";
if(!freopen(intent, "w", stdout)) goto catch;
scan_labs_graph(&scn);
intent = "glider.gnu";
if(!freopen(intent, "w", stdout)) goto catch;
scan_glider_graph(&scn);
@ -84,6 +92,10 @@ int main(void) {
goto finally;
catch:
perror(intent);
/* Don't know if that will give real insight into the problem… */
if(freopen("error.txt", "w", stdout)) {
printf("Journal: %s.\n", journal_to_string(&jrnl));
}
finally:
/* fixme: ~scan should be idempotent but it's not on disabling ASLR, which
debug mode is in. */

View File

@ -147,7 +147,7 @@ struct scan {
} edits;
struct linepair_tree dreams;
struct linekvpair_tree contacts, books, tvs, movies, ideas,
vaccines, medications, mails, couches;
vaccines, medications, labs, mails, couches;
struct linekvdate_tree froms;
struct linekvmoney_tree taxes, incomes;
struct glider_tree gliders;
@ -159,6 +159,7 @@ void scan_(struct scan *);
struct scan scan(struct journal *);
const struct kvpair *scan_source_lookup(struct scan *, const union line64);
void scan_score_graph(struct scan *);
void scan_labs_graph(struct scan *);
void scan_glider_graph(struct scan *);
void scan_flight_graph(struct scan *);
void scan_kjv_graph(struct scan *);

View File

@ -256,6 +256,7 @@ static int scan_day(struct scan *const scan, union date32 date,
<bracket> "idea: " :=> idea
<bracket> "vaccine: " :=> vaccine
<bracket> "medication: " :=> medication
<bracket> "lab: " :=> lab
<bracket> "tax: " :=> tax
<bracket> "in: " :=> income
<bracket> "mail: " :=> mail
@ -436,6 +437,22 @@ static int scan_day(struct scan *const scan, union date32 date,
continue;
}
<lab> * { fail = "lab unrecognized"; goto catch; }
<lab> @s0 bralabel @s1 "]" => input_text {
const union line64 key = { { (uint32_t)line, date } };
struct kvpair *pair;
switch(linekvpair_tree_bulk_assign(&scan->labs, key, &pair)) {
case TREE_PRESENT: fail = "duplicate"; case TREE_ERROR: goto catch;
case TREE_ABSENT: break;
}
pair->key.a = s0, pair->key.b = s1;
pair->value.a = pair->value.b = 0;
input.future = yycnewline, input.pair = &pair->value;
fprintf(stderr, "%s:%zu: new lab <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
<tax> * { fail = "tax unrecognized"; goto catch; }
<tax> @s0 bralabel @s1 "]" => input_money {
const union line64 key = { { (uint32_t)line, date } };
@ -989,6 +1006,7 @@ void scan_(struct scan *const scan) {
linekvmoney_tree_(&scan->taxes);
linekvdate_tree_(&scan->froms);
linekvpair_tree_(&scan->couches);
linekvpair_tree_(&scan->labs);
linekvpair_tree_(&scan->medications);
linekvpair_tree_(&scan->vaccines);
linekvpair_tree_(&scan->ideas);
@ -1070,6 +1088,7 @@ struct scan scan(struct journal *const jrnl) {
|| !linekvpair_tree_bulk_finish(&scan.ideas)
|| !linekvpair_tree_bulk_finish(&scan.vaccines)
|| !linekvpair_tree_bulk_finish(&scan.medications)
|| !linekvpair_tree_bulk_finish(&scan.labs)
|| !linekvpair_tree_bulk_finish(&scan.couches)
|| !linekvdate_tree_bulk_finish(&scan.froms)
|| !linekvmoney_tree_bulk_finish(&scan.taxes)
@ -1193,6 +1212,27 @@ void scan_score_graph(struct scan *const scan) {
fprintf(stderr, "\n");
}
void scan_labs_graph(struct scan *const scan) {
struct linekvpair_tree_iterator it
= linekvpair_tree_iterator(&scan->labs);
union line64 line;
struct kvpair *kv;
assert(scan);
fprintf(stderr, "*** Labs graph %s.\n",
linekvpair_tree_to_string(&scan->labs));
while(linekvpair_tree_next(&it)) {
char datestr[12];
line = linekvpair_tree_key(&it);
kv = linekvpair_tree_value(&it);
date32_to_string(line.date, &datestr);
printf("%s, \"%.*s\", \"%.*s\"\n",
datestr, (int)(kv->key.b - kv->key.a), kv->key.a,
(int)(kv->value.b - kv->value.a), kv->value.a);
}
fprintf(stderr, "\n");
}
#include <inttypes.h>
void scan_glider_graph(struct scan *const scan) {

3
time.txt Normal file
View File

@ -0,0 +1,3 @@
set xdata time
set timefmt myTimeFmt
set xrange ['2000-01-01':*]