jounal_is_valid removed -- check errno
This commit is contained in:
parent
e9dcc1d3bc
commit
0039d6d297
@ -212,8 +212,7 @@ static int scan(struct flights *const f,
|
||||
catch:
|
||||
if(!errno) errno = EILSEQ;
|
||||
date32_to_string(date, &datestr);
|
||||
fprintf(stderr, "%s\n"
|
||||
"%s line %zu: %s.\n", text, datestr, line, why);
|
||||
fprintf(stderr, "%s line %zu: %s.\n", datestr, line, why);
|
||||
return 0;
|
||||
}
|
||||
/** Dynamic memory allocation for `f` will be zero, <fn:flights_is_valid> will
|
||||
|
@ -35,7 +35,7 @@ struct journal { struct day_tree days; struct text backing; };
|
||||
struct journal_iterator { struct day_tree_iterator _; };
|
||||
struct journal journal(void);
|
||||
void journal_(struct journal *);
|
||||
//int journal_is_valid(const struct journal *);
|
||||
/*int journal_is_valid(const struct journal *);*/
|
||||
const char *journal_to_string(const struct journal *);
|
||||
struct journal_iterator journal_iterator(struct journal *const j);
|
||||
int journal_next(struct journal_iterator *, union date32 *, const char **);
|
||||
|
@ -102,8 +102,7 @@ static unsigned looks_like_day(const char *const a) {
|
||||
#define PROTO
|
||||
#include "../src/journal.h" /* Just prototypes. */
|
||||
|
||||
/** Dynamic memory allocation for `j` will be zero, <fn:journal_is_valid> will
|
||||
be false. */
|
||||
/** Erases memory allocation for `j`. */
|
||||
void journal_(struct journal *const j) {
|
||||
if(!j) return;
|
||||
day_tree_(&j->days);
|
||||
@ -176,8 +175,8 @@ struct journal journal(void) {
|
||||
}
|
||||
if(closedir(dir)) { dir = 0; goto catch; } dir = 0;
|
||||
qsort(days.data, days.size, sizeof *days.data, &void_int_cmp);
|
||||
fprintf(stderr, "Days in <<%s>>: %s.\n",
|
||||
fn, int_array_to_string(&days));
|
||||
/*fprintf(stderr, "Days in <<%s>>: %s.\n",
|
||||
fn, int_array_to_string(&days)); <- Too much spam. */
|
||||
|
||||
for(d = days.data, d_end = d + days.size; d < d_end; d++) {
|
||||
const union date32 d32 = { .year = (uint32_t)*y,
|
||||
@ -227,9 +226,9 @@ finally:
|
||||
}
|
||||
|
||||
/** @return `j` read in some data? */
|
||||
int journal_is_valid(const struct journal *const j) {
|
||||
/*int journal_is_valid(const struct journal *const j) {
|
||||
return j && j->days.root.node && j->backing.a.data;
|
||||
}
|
||||
}*/
|
||||
|
||||
/** @return `j` as a string. */
|
||||
const char *journal_to_string(const struct journal *const j)
|
||||
|
@ -184,13 +184,15 @@ catch:
|
||||
|
||||
int main(void) {
|
||||
int success = EXIT_SUCCESS;
|
||||
errno = 0;
|
||||
struct journal j;
|
||||
struct journal_iterator it;
|
||||
struct kjv bible = kjv();
|
||||
if(errno) goto catch;
|
||||
union date32 k;
|
||||
const char *v;
|
||||
j = journal();
|
||||
if(!journal_is_valid(&j)) goto catch;
|
||||
if(errno) goto catch;
|
||||
fprintf(stderr, "Journal: %s.\n", journal_to_string(&j));
|
||||
printf("set term postscript eps enhanced\n"
|
||||
"set output \"kjv.eps\"\n"
|
||||
|
@ -134,8 +134,7 @@ static int scan(union date32 date, const char *const buffer,
|
||||
catch:
|
||||
if(!errno) errno = EILSEQ;
|
||||
date32_to_string(date, &datestr);
|
||||
fprintf(stderr, "%s\n"
|
||||
"%s line %zu: %s.\n", buffer, datestr, line, why);
|
||||
fprintf(stderr, "%s line %zu: %s.\n", datestr, line, why);
|
||||
return 0;
|
||||
}
|
||||
/** Dynamic memory allocation for `s` will be zero. */
|
||||
|
@ -3,11 +3,13 @@
|
||||
#include <inttypes.h> /* C99 */
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
int main(void) {
|
||||
errno = 0;
|
||||
struct journal j = journal();
|
||||
int success = EXIT_SUCCESS;
|
||||
if(!journal_is_valid(&j)) goto catch;
|
||||
if(errno) goto catch;
|
||||
printf("Journal: %s.\n", journal_to_string(&j));
|
||||
{
|
||||
struct journal_iterator it = journal_iterator(&j);
|
||||
|
Loading…
Reference in New Issue
Block a user