diff options
Diffstat (limited to 'fcomp.c')
-rw-r--r-- | fcomp.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -161,7 +161,7 @@ static void print_help(char *argv0) "Set extra invalid chars for tokens"); fprintf(stderr, "%8s %4s %15s %50s\n", "-w", "[..]", "word length", "Set min word length to count as token"); - fprintf(stderr, "%8s %4s %15s %50s\n\n", "-t", "[..]", "toekn length", + fprintf(stderr, "%8s %4s %15s %50s\n\n", "-t", "[..]", "token length", "Set max token length to parse"); fprintf(stderr, "%8s %4s %15s %50s\n", "-d", "", "debug", "Show debug information"); @@ -739,6 +739,8 @@ static int set_input(FILE **f) } *f = stdin; } else if (cfg.filestream) { + if (!cfg.file || strcmp(cfg.file, "") == 0) + return -1; *f = fmemopen(cfg.file, strlen(cfg.file), "r"); } else { *f = fopen(cfg.file, "r"); @@ -767,7 +769,7 @@ static void get_uniq(slist * l, result *r) int main(int argc, char *argv[]) { int rc = 0; - FILE *f; + FILE *f = NULL; slist token_list = { 0 }; slist ref_list = { 0 }; slist *listp = NULL; @@ -831,6 +833,6 @@ int main(int argc, char *argv[]) done: sfree(&token_list); - fclose(f); + if (f) fclose(f); return rc; } |