diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2019-06-16 11:47:50 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2019-06-16 11:47:50 +0300 |
commit | 41a0806297ad6e31c33a9d25b0138a5ae90546d8 (patch) | |
tree | c9913eff0d38fa8a7aed904958dc870888020596 /fcomp.c | |
parent | 37c11b6c4959c1c4f3bcdf576d1148e72e01cb67 (diff) | |
download | fcomp-41a0806297ad6e31c33a9d25b0138a5ae90546d8.tar.gz fcomp-41a0806297ad6e31c33a9d25b0138a5ae90546d8.tar.bz2 fcomp-41a0806297ad6e31c33a9d25b0138a5ae90546d8.zip |
Fix check for valid file, add -F to help
Diffstat (limited to 'fcomp.c')
-rw-r--r-- | fcomp.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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; } |