X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=selector.c;h=effd0140b760a4c8a0048e9f1cfbe8dec1e9e32b;hb=1c1b9424c49bab51042fbd3730afa38bcd8b4f07;hp=cf90315203ec9a8ddb62d3dbfca5992df5efb971;hpb=5bf2fa971b48efef58ec6127b26f259c55ebc16d;p=selector.git diff --git a/selector.c b/selector.c index cf90315..effd014 100644 --- a/selector.c +++ b/selector.c @@ -410,25 +410,6 @@ int match(struct matcher *matcher, char *string, int *nb_switches, int *switches *nb_switches = add_interval(*nb_switches, switches, (int) (where - string), (int) (where - string) + strlen(matcher->patterns[n])); -#warning CHECK THE INTERVALS - { - /* int i; */ - /* FILE *out = fopen("/tmp/intervals", "w"); */ - /* for(k = 0; k < (*nb_switches)/2; k++) { */ - /* i = 0; */ - /* for(; i < switches[2 * k]; i++) fprintf(out, "-"); */ - /* for(; i < switches[2 * k + 1]; i++) fprintf(out, "%c", string[i]); */ - /* for(; i < strlen(string); i++) fprintf(out, "-"); */ - /* fprintf(out, "\n"); */ - /* } */ - /* fclose(out); */ - int k; - for(k = 0; k < *nb_switches - 1; k++) { - if(switches[k] > switches[k+1]) { - abort(); - } - } - } } } } @@ -643,10 +624,14 @@ void update_screen(int *current_focus_line, int *displayed_focus_line, initialize_matcher(&matcher, use_regexp, case_sensitive, pattern); - if(show_hits && matcher.nb_patterns >= 0) { - switches = safe_malloc(sizeof(int) * matcher.nb_patterns * 2); + if(show_hits) { + if(matcher.nb_patterns >= 0) { + switches = safe_malloc(sizeof(int) * matcher.nb_patterns * 2); + } else { + switches = safe_malloc(sizeof(int) * 2); + } } else { - switches = safe_malloc(sizeof(int) * 2); + switches = 0; } console_width = getmaxx(stdscr);