~smlavine/navipage

3bb0ab76fa269f2d7693ae84e490b5199587eec0 — Sebastian LaVine 9 months ago d0e1646
Add ewarn() and warn() calls to error_buffer() calls
1 files changed, 3 insertions(+), 1 deletions(-)

M main.c
M main.c => main.c +3 -1
@@ 533,6 533,7 @@ init_buffer(Buffer *const b, const char *const path)
	if ( (errfunc = "fopen", (fp = fopen(path, "r")) == NULL) ||
	     (errfunc = "fseek", fseek(fp, 0L, SEEK_END) == -1)   ||
	     (errfunc = "ftell", (b->length = ftell(fp)) == -1) ) {
		ewarn("cannot %s %s", errfunc, path);
		error_buffer(b, "%s: cannot %s %s: %s\n",
				argv0, errfunc, path, strerror(errno));
		return -1;


@@ 543,7 544,8 @@ init_buffer(Buffer *const b, const char *const path)
	if ((b->text = malloc(sizeof(*b->text) * b->size)) == NULL)
		err(EXIT_FAILURE, "malloc failed");
	if (fread(b->text, sizeof(char), b->length, fp) != (size_t)b->length) {
		error_buffer(b, "%s: fread failed on '%s'\n", argv0, path);
		warn("fread failed on %s\n", path);
		error_buffer(b, "%s: fread failed on %s\n", argv0, path);
		return -1;
	}