Permalink
Browse files

implemented printing of scores in gpicker-simple

  • Loading branch information...
1 parent c44e7b6 commit aaa2d0c6561b4f406ebd0773189adf72b47e5285 Aliaksey Kandratsenka committed Jan 3, 2010
Showing with 17 additions and 2 deletions.
  1. +3 −0 gpicker-simple.1
  2. +14 −2 simple_main.c
View
@@ -39,6 +39,9 @@ Don't sort filtered list
.B \-M
Output match positions
.TP
+.B \-x
+Print match scores too
+.TP
.B \-n name\-separator
Sets separator of filenames from stdin (\\0 is default).
Interprets \\0 as zero byte, \\n as new line, \\r as carriage return, \\t
View
@@ -16,6 +16,8 @@ static
char *pattern;
static
int output_match;
+static
+int output_scores;
static
void process_separator(char **separator_place, char *name, char *def)
@@ -44,7 +46,7 @@ void process_separator(char **separator_place, char *name, char *def)
static
void usage(void)
{
- fputs("usage: gpicker-simple [-hSM] [-d dir-seperator] [-n name-separator] pattern\n", stderr);
+ fputs("usage: gpicker-simple [-hSMx] [-d dir-seperator] [-n name-separator] pattern\n", stderr);
exit(0);
}
@@ -55,7 +57,7 @@ void parse_options(int argc, char **argv)
name_separator = "\n";
- while ((ch = getopt(argc, argv, "hn:d:SM")) > 0) {
+ while ((ch = getopt(argc, argv, "hn:d:SMx")) > 0) {
switch (ch) {
case 'h':
case '?':
@@ -71,6 +73,9 @@ void parse_options(int argc, char **argv)
break;
case 'M':
output_match = 1;
+ break;
+ case 'x':
+ output_scores = 1;
}
}
@@ -109,6 +114,13 @@ int simple_main(int argc, char **argv)
int index = results[i].index;
char *p = files[index].p;
fputs(p, stdout);
+ if (output_scores) {
+ struct filter_result *r = results + i;
+ if (r->dirscore)
+ printf(":%x:%x", r->score, r->dirscore);
+ else
+ printf(":%x", r->score);
+ }
fputc(name_separator[0], stdout);
if (output_match) {

0 comments on commit aaa2d0c

Please sign in to comment.