summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2019-06-16 11:47:50 +0300
committergramanas <anastasis.gramm2@gmail.com>2019-06-16 11:47:50 +0300
commit41a0806297ad6e31c33a9d25b0138a5ae90546d8 (patch)
treec9913eff0d38fa8a7aed904958dc870888020596
parent37c11b6c4959c1c4f3bcdf576d1148e72e01cb67 (diff)
downloadfcomp-41a0806297ad6e31c33a9d25b0138a5ae90546d8.tar.gz
fcomp-41a0806297ad6e31c33a9d25b0138a5ae90546d8.tar.bz2
fcomp-41a0806297ad6e31c33a9d25b0138a5ae90546d8.zip
Fix check for valid file, add -F to help
-rw-r--r--fcomp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fcomp.c b/fcomp.c
index bff6823..65f5812 100644
--- a/fcomp.c
+++ b/fcomp.c
@@ -144,6 +144,8 @@ static void print_help(char *argv0)
"Same");
fprintf(stderr, "%8s %4s %15s %50s\n", "-f", "[..]", "file",
"Select the input file to use");
+ fprintf(stderr, "%8s %4s %15s %50s\n", "-F", "[..]", "filestream",
+ "Input can be provided as a string");
fprintf(stderr, "%8s %4s %15s %50s\n", "stdin", "[..]", "",
"Input can come from rediretion as well as files");
fprintf(stderr, "%8s %4s %15s %50s\n", "-z", "", "fuzzy",
@@ -688,9 +690,11 @@ static int set_input(FILE **f)
if (!cfg.file || strcmp(cfg.file, "") == 0)
return -1;
*f = fmemopen(cfg.file, strlen(cfg.file), "r");
- } else {
+ if (!*f) return -1;
+ }
+ else {
*f = fopen(cfg.file, "r");
- if (!f) {
+ if (!*f) {
fprintf(stderr, "Couldn't open %s\n", cfg.file);
return -1;
}