diff options
author | Yuuta Liang <yuuta@yuuta.moe> | 2023-06-24 18:49:59 -0700 |
---|---|---|
committer | Yuuta Liang <yuuta@yuuta.moe> | 2023-06-24 18:49:59 -0700 |
commit | 46cfd5e3901a59d1912baca41283dab157f5dd8b (patch) | |
tree | d7b6d05d9b34059e7892dc1f85b61c10ceed3a5a /main.c | |
parent | 5806db57d066139eb3e38637960a6866e69948ed (diff) | |
download | regpol-master.tar regpol-master.tar.gz regpol-master.tar.bz2 regpol-master.zip |
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -18,7 +18,6 @@ #include <stdio.h> #include <stdlib.h> #include <errno.h> -#include <err.h> #include <stdint.h> #include <stdbool.h> #include <string.h> @@ -139,19 +138,22 @@ int main(int argc, char **argv) { } FILE *pol = fopen(path, "r"); if (!pol) { - err(errno, "Cannot open %s", path); + fprintf(stderr, "Cannot open %s: %s\n", path, strerror(errno)); + return errno; } for (; !feof(pol) && !ferror(pol); ) { void *b = realloc(buf, buf_len += READ_INCREMENT); if (!b) { - err(errno, "Cannot allocate memory"); + fprintf(stderr, "Cannot allocate memory: %s\n", strerror(errno)); + return errno; } buf = b; pol_len += fread((void *)(buf + pol_len), 1, READ_INCREMENT, pol); } if (ferror(pol)) { - err(ferror(pol), "Cannot read the file"); + fprintf(strerror, "Cannot read the file: %s\n", strerror(ferror(pol))); + return ferror(pol); } fclose(pol); pol = NULL; |