diff options
| -rw-r--r-- | txt.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -147,12 +147,13 @@ u32 txt_delete_c(Txt *b, u32 cur) { int txt_load(Txt *b, const char *path) { struct stat sb; int fd = open(path, O_RDONLY); - if (fd == -1) return -1; + if (fd == -1) goto empty_file; if (fstat(fd, &sb)) { close(fd); return -1; } if (!sb.st_size) { +empty_file: txt_buf_fit(b, TXT_SRC, 8192); goto done; } @@ -175,7 +176,7 @@ done: } int txt_save(Txt *t, const char *path) { - FILE *f = fopen(path, "w"); + FILE *f = fopen(path, "wb"); if (!f) return -1; for (u32 i = 0; i < t->ptbl.n; i++) { TxtPiece *p = &t->ptbl.v[i]; |
