From 5c903e08600ee2c65ea24c3c8b4ef2a12db2afbd Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Sun, 28 Dec 2025 04:58:35 -0500 Subject: ferror in the right place --- txt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'txt.c') diff --git a/txt.c b/txt.c index 9046b79..0b13a9e 100644 --- a/txt.c +++ b/txt.c @@ -182,8 +182,9 @@ int txt_save(Txt *t, const char *path) { TxtBuf *b = &t->buf[p->buf]; fwrite(b->s + p->ofs, 1, p->n, f); } + int e = ferror(f); fclose(f); - return ferror(f) ? -1 : 0; + return e ? -1 : 0; } void txt_free(Txt *t) { -- cgit v1.2.3