summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2019-03-23 23:04:26 +0200
committergramanas <anastasis.gramm2@gmail.com>2019-03-23 23:04:26 +0200
commit941dfd02e0bff82368325c9237398b0944aefda3 (patch)
tree764d16b9c09f453b2e1c201203ba660d3706efbf
parent725d97bba026e8916d928d96c77b1d6c3743a98c (diff)
downloadfcomp-941dfd02e0bff82368325c9237398b0944aefda3.tar.gz
fcomp-941dfd02e0bff82368325c9237398b0944aefda3.tar.bz2
fcomp-941dfd02e0bff82368325c9237398b0944aefda3.zip
Add -q option & fix bug with -u
-rw-r--r--fcomp.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fcomp.c b/fcomp.c
index a41c75d..c10fc2e 100644
--- a/fcomp.c
+++ b/fcomp.c
@@ -131,8 +131,10 @@ static void print_help(char *argv0)
"~~~~~~~~~~~");
fprintf(stderr, "%8s %4s %15s %50s\n\n", "-h", "", "help",
"Print this help message");
- fprintf(stderr, "%8s %4s %15s %50s\n", "query", "[..]", "",
+ fprintf(stderr, "%8s %4s %15s %50s\n", "query", "", "",
"The term to be matched agains the tokens");
+ fprintf(stderr, "%8s %4s %15s %50s\n", "-q", "[..]", "query",
+ "Same");
fprintf(stderr, "%8s %4s %15s %50s\n", "-f", "[..]", "file",
"Select the input file to use");
fprintf(stderr, "%8s %4s %15s %50s\n", "stdin", "[..]", "",
@@ -223,7 +225,7 @@ static int parse_cli(int argc, char *argv[])
if (argc < 2)
return -1;
char c;
- while ((c = getopt(argc, argv, "-hIF:xzsaudclrf:i:v:w:t:")) != -1) {
+ while ((c = getopt(argc, argv, "-hIxzsaudclrq:F:f:i:v:w:t:")) != -1) {
switch (c) {
case 'I':
if (cfg.interactive) {
@@ -285,6 +287,7 @@ static int parse_cli(int argc, char *argv[])
cfg.reverse_sort = 1;
break;
case '\1':
+ case 'q':
cfg.query = optarg;
break;
case '?':
@@ -817,9 +820,11 @@ int main(int argc, char *argv[])
}
if (listp) {
- get_uniq(listp, &count_res);
- pc(&count_res);
- cfree(&count_res);
+ if (listp->n != 0) {
+ get_uniq(listp, &count_res);
+ pc(&count_res);
+ cfree(&count_res);
+ }
if (listp == &ref_list)
free(ref_list.s);