summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuuta Liang <yuuta@yuuta.moe>2023-06-24 18:49:59 -0700
committerYuuta Liang <yuuta@yuuta.moe>2023-06-24 18:49:59 -0700
commit46cfd5e3901a59d1912baca41283dab157f5dd8b (patch)
treed7b6d05d9b34059e7892dc1f85b61c10ceed3a5a
parent5806db57d066139eb3e38637960a6866e69948ed (diff)
downloadregpol-46cfd5e3901a59d1912baca41283dab157f5dd8b.tar
regpol-46cfd5e3901a59d1912baca41283dab157f5dd8b.tar.gz
regpol-46cfd5e3901a59d1912baca41283dab157f5dd8b.tar.bz2
regpol-46cfd5e3901a59d1912baca41283dab157f5dd8b.zip
Make it portableHEADmaster
-rw-r--r--main.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/main.c b/main.c
index 46bfedb..f9d7b42 100644
--- a/main.c
+++ b/main.c
@@ -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;