From bfffbde2387b985b2864f508cba952a0c016eccc Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 10 Mar 2023 20:06:11 -0800 Subject: [PATCH] errno=0 before --- src/kjv.re.c | 5 +++++ src/scan_kjv.re.c | 5 ++++- src/text.c | 2 +- test/test_journal.c | 2 +- test/test_kjv.c | 3 ++- test/test_source.c | 2 +- test/test_text.c | 2 ++ 7 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/kjv.re.c b/src/kjv.re.c index f2ce3aa..e6d9a07 100644 --- a/src/kjv.re.c +++ b/src/kjv.re.c @@ -213,9 +213,14 @@ catch: recatch: kjv_(&kjv); finally: + printf("kjv: %s.\n", kjv_to_string(&kjv)); + printf("kjv: closedir errno %d\n", errno); if(dir) { if(closedir(dir)) { dir = 0; goto recatch; } dir = 0; } + printf("kjv: is_in_kjv errno %d\n", errno); if(is_in_kjv && (is_in_kjv = 0, chdir("..") == -1)) goto recatch; + printf("kjv: ~text(backing) errno %d\n", errno); text_(&backing); + printf("kjv: %p errno %d\n", (void *)&kjv, errno); return kjv; } diff --git a/src/scan_kjv.re.c b/src/scan_kjv.re.c index f23c663..9690364 100644 --- a/src/scan_kjv.re.c +++ b/src/scan_kjv.re.c @@ -187,10 +187,12 @@ int main(void) { errno = 0; struct journal j; struct journal_iterator it; + printf("1. kjv\n"); struct kjv bible = kjv(); - if(errno) goto catch; + if(errno) { printf("kjv?\n"); goto catch; } union date32 k; const char *v; + printf("2. journal\n"); j = journal(); if(errno) goto catch; fprintf(stderr, "Journal: %s.\n", journal_to_string(&j)); @@ -219,6 +221,7 @@ catch: success = EXIT_FAILURE; perror("journal"); finally: + kjv_(&bible); journal_(&j); return success; } diff --git a/src/text.c b/src/text.c index 87072e7..0624af0 100644 --- a/src/text.c +++ b/src/text.c @@ -42,6 +42,6 @@ finally: } struct text text(void) { struct text text; text.a = char_array(); return text; } -void text_(struct text *const text) { char_array_(&text->a); } +void text_(struct text *const text) { printf("~text: errno %d text.a.data %p\n", errno, (void *)text->a.data); char_array_(&text->a); printf("~text: errno %d\n", errno); } char *text_append_file(struct text *text, const char *const fn) { return append_file(&text->a, fn); } diff --git a/test/test_journal.c b/test/test_journal.c index 3c42796..c42a468 100644 --- a/test/test_journal.c +++ b/test/test_journal.c @@ -6,7 +6,7 @@ #include int main(void) { - errno = 0; + errno = 0; /* `errno` is not set correctly to 0 in some debug situations. */ struct journal j = journal(); int success = EXIT_SUCCESS; if(errno) goto catch; diff --git a/test/test_kjv.c b/test/test_kjv.c index 71cfe58..4fd3bbb 100644 --- a/test/test_kjv.c +++ b/test/test_kjv.c @@ -1,12 +1,13 @@ -#define KJV_TEST #include "../src/kjv.h" #include #include /* C99 */ #include #include +#include int main(void) { int success = EXIT_SUCCESS; + errno = 0; /* `errno` is not set correctly to 0 in some debug situations. */ struct kjv k = kjv(); fprintf(stderr, "%zu total words, %s.\n", k.words.total, kjv_to_string(&k)); if(!kjv_is_valid(&k)) goto catch; diff --git a/test/test_source.c b/test/test_source.c index fe0528a..c8bda35 100644 --- a/test/test_source.c +++ b/test/test_source.c @@ -7,7 +7,7 @@ int main(void) { int success = EXIT_SUCCESS; - errno = 0; + errno = 0; /* `errno` is not set correctly to 0 in some debug situations. */ struct journal j = journal(); struct sources s = sources(&j); if(errno) goto catch; diff --git a/test/test_text.c b/test/test_text.c index 1be9618..bdfbcce 100644 --- a/test/test_text.c +++ b/test/test_text.c @@ -1,11 +1,13 @@ #include "../src/text.h" #include #include +#include int main(void) { struct text t = text(); char *content; int success = EXIT_SUCCESS; + errno = 0; /* `errno` is not set correctly to 0 in some debug situations. */ if(!(content = text_append_file(&t, "Makefile"))) goto catch; printf("%s", content); goto finally;