#
# This is a patch for the find file stuff, from Gentoo.
#
# (not completely sure what it *really* does, but it seems to
# have something to do w/ case sensitivity)
#
# Source: Gentoo Portage
# Reference: mc-4.6.1
# Submit-By: Enrico Weigelt, metux IT service <weigelt metux de>
# Submit-Date: 2008-12-16
# State: new
#
diff -Naur mc-4.6.1.orig/src/cmd.c mc-4.6.1/src/cmd.c
old
|
new
|
|
510 | 510 | continue; |
511 | 511 | } |
512 | 512 | c = regexp_match (reg_exp_t, current_panel->dir.list[i].fname, |
513 | | match_file); |
| 513 | match_file, 0); |
514 | 514 | if (c == -1) { |
515 | 515 | message (1, MSG_ERROR, _(" Malformed regular expression ")); |
516 | 516 | g_free (reg_exp); |
diff -Naur mc-4.6.1.orig/src/dir.c mc-4.6.1/src/dir.c
old
|
new
|
|
405 | 405 | *stale_link = 1; |
406 | 406 | } |
407 | 407 | if (!(S_ISDIR (buf1->st_mode) || *link_to_dir) && filter |
408 | | && !regexp_match (filter, dp->d_name, match_file)) |
| 408 | && !regexp_match (filter, dp->d_name, match_file, 0)) |
409 | 409 | return 0; |
410 | 410 | |
411 | 411 | /* Need to grow the *list? */ |
diff -Naur mc-4.6.1.orig/src/ext.c mc-4.6.1/src/ext.c
old
|
new
|
|
394 | 394 | } |
395 | 395 | |
396 | 396 | if (content_string[0] |
397 | | && regexp_match (ptr, content_string + content_shift, match_regex)) { |
| 397 | && regexp_match (ptr, content_string + content_shift, match_regex, 0)) { |
398 | 398 | found = 1; |
399 | 399 | } |
400 | 400 | |
… |
… |
|
534 | 534 | /* Do not transform shell patterns, you can use shell/ for |
535 | 535 | * that |
536 | 536 | */ |
537 | | if (regexp_match (p, filename, match_regex)) |
| 537 | if (regexp_match (p, filename, match_regex, 0)) |
538 | 538 | found = 1; |
539 | 539 | } else if (!strncmp (p, "directory/", 10)) { |
540 | 540 | if (S_ISDIR (mystat.st_mode) |
541 | | && regexp_match (p + 10, filename, match_regex)) |
| 541 | && regexp_match (p + 10, filename, match_regex, 0)) |
542 | 542 | found = 1; |
543 | 543 | } else if (!strncmp (p, "shell/", 6)) { |
544 | 544 | p += 6; |
diff -Naur mc-4.6.1.orig/src/find.c mc-4.6.1/src/find.c
old
|
new
|
|
575 | 575 | struct stat tmp_stat; |
576 | 576 | static int pos; |
577 | 577 | static int subdirs_left = 0; |
| 578 | int flags = 0; |
578 | 579 | |
579 | 580 | if (!h) { /* someone forces me to close dirp */ |
580 | 581 | if (dirp) { |
… |
… |
|
586 | 587 | dp = 0; |
587 | 588 | return 1; |
588 | 589 | } |
| 590 | |
| 591 | if (!(case_sense->state & C_BOOL)) |
| 592 | flags |= REG_ICASE; |
| 593 | |
589 | 594 | do_search_begin: |
590 | 595 | while (!dp){ |
591 | 596 | |
… |
… |
|
662 | 667 | g_free (tmp_name); |
663 | 668 | } |
664 | 669 | |
665 | | if (regexp_match (find_pattern, dp->d_name, match_file)){ |
| 670 | if (regexp_match (find_pattern, dp->d_name, match_file, flags)){ |
666 | 671 | if (content_pattern) { |
667 | 672 | if (search_content (h, directory, dp->d_name)) { |
668 | 673 | return 1; |
diff -Naur mc-4.6.1.orig/src/user.c mc-4.6.1/src/user.c
old
|
new
|
|
412 | 412 | break; |
413 | 413 | case 'f': /* file name pattern */ |
414 | 414 | p = extract_arg (p, arg, sizeof (arg)); |
415 | | *condition = panel && regexp_match (arg, panel->dir.list [panel->selected].fname, match_file); |
| 415 | *condition = panel && regexp_match (arg, panel->dir.list [panel->selected].fname, match_file, 0); |
416 | 416 | break; |
417 | 417 | case 'y': /* syntax pattern */ |
418 | 418 | if (edit_widget && edit_widget->syntax_type) { |
419 | 419 | p = extract_arg (p, arg, sizeof (arg)); |
420 | 420 | *condition = panel && |
421 | | regexp_match (arg, edit_widget->syntax_type, match_normal); |
| 421 | regexp_match (arg, edit_widget->syntax_type, match_normal, 0); |
422 | 422 | } |
423 | 423 | break; |
424 | 424 | case 'd': |
425 | 425 | p = extract_arg (p, arg, sizeof (arg)); |
426 | | *condition = panel && regexp_match (arg, panel->cwd, match_file); |
| 426 | *condition = panel && regexp_match (arg, panel->cwd, match_file, 0); |
427 | 427 | break; |
428 | 428 | case 't': |
429 | 429 | p = extract_arg (p, arg, sizeof (arg)); |
diff -Naur mc-4.6.1.orig/src/util.c mc-4.6.1/src/util.c
old
|
new
|
|
563 | 563 | return g_strdup (pattern); |
564 | 564 | } |
565 | 565 | |
566 | | int regexp_match (const char *pattern, const char *string, int match_type) |
| 566 | int regexp_match (const char *pattern, const char *string, int match_type, int flags) |
567 | 567 | { |
568 | 568 | static regex_t r; |
569 | 569 | static char *old_pattern = NULL; |
570 | 570 | static int old_type; |
| 571 | static int old_flags; |
571 | 572 | int rval; |
572 | 573 | char *my_pattern; |
573 | 574 | |
574 | | if (!old_pattern || STRCOMP (old_pattern, pattern) || old_type != match_type){ |
| 575 | if (!old_pattern || STRCOMP (old_pattern, pattern) || old_type != match_type || old_flags != flags){ |
575 | 576 | if (old_pattern){ |
576 | 577 | regfree (&r); |
577 | 578 | g_free (old_pattern); |
578 | 579 | old_pattern = NULL; |
579 | 580 | } |
580 | 581 | my_pattern = convert_pattern (pattern, match_type, 0); |
581 | | if (regcomp (&r, my_pattern, REG_EXTENDED|REG_NOSUB|MC_ARCH_FLAGS)) { |
| 582 | |
| 583 | if (regcomp (&r, my_pattern, REG_EXTENDED|REG_NOSUB|MC_ARCH_FLAGS|flags)) { |
582 | 584 | g_free (my_pattern); |
583 | 585 | return -1; |
584 | 586 | } |
585 | 587 | old_pattern = my_pattern; |
586 | 588 | old_type = match_type; |
| 589 | old_flags = flags; |
587 | 590 | } |
588 | 591 | rval = !regexec (&r, string, 0, NULL, 0); |
589 | 592 | return rval; |
diff -Naur mc-4.6.1.orig/src/util.h mc-4.6.1/src/util.h
old
|
new
|
|
116 | 116 | |
117 | 117 | extern int easy_patterns; |
118 | 118 | char *convert_pattern (const char *pattern, int match_type, int do_group); |
119 | | int regexp_match (const char *pattern, const char *string, int match_type); |
| 119 | int regexp_match (const char *pattern, const char *string, int match_type, int flags); |
120 | 120 | |
121 | 121 | /* Error pipes */ |
122 | 122 | void open_error_pipe (void); |