Ticket #95: icase-files-find.patch

File icase-files-find.patch, 5.7 KB (added by slavazanko, 15 years ago)
  • src/cmd.c

    #
    # 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  
    510510                continue; 
    511511        } 
    512512        c = regexp_match (reg_exp_t, current_panel->dir.list[i].fname, 
    513                           match_file); 
     513                          match_file, 0); 
    514514        if (c == -1) { 
    515515            message (1, MSG_ERROR, _("  Malformed regular expression  ")); 
    516516            g_free (reg_exp); 
  • src/dir.c

    diff -Naur mc-4.6.1.orig/src/dir.c mc-4.6.1/src/dir.c
    old new  
    405405            *stale_link = 1; 
    406406    } 
    407407    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)) 
    409409        return 0; 
    410410 
    411411    /* Need to grow the *list? */ 
  • src/ext.c

    diff -Naur mc-4.6.1.orig/src/ext.c mc-4.6.1/src/ext.c
    old new  
    394394    } 
    395395 
    396396    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)) { 
    398398        found = 1; 
    399399    } 
    400400 
     
    534534                /* Do not transform shell patterns, you can use shell/ for 
    535535                 * that 
    536536                 */ 
    537                 if (regexp_match (p, filename, match_regex)) 
     537                if (regexp_match (p, filename, match_regex, 0)) 
    538538                    found = 1; 
    539539            } else if (!strncmp (p, "directory/", 10)) { 
    540540                if (S_ISDIR (mystat.st_mode) 
    541                     && regexp_match (p + 10, filename, match_regex)) 
     541                    && regexp_match (p + 10, filename, match_regex, 0)) 
    542542                    found = 1; 
    543543            } else if (!strncmp (p, "shell/", 6)) { 
    544544                p += 6; 
  • src/find.c

    diff -Naur mc-4.6.1.orig/src/find.c mc-4.6.1/src/find.c
    old new  
    575575    struct stat tmp_stat; 
    576576    static int pos; 
    577577    static int subdirs_left = 0; 
     578    int flags = 0; 
    578579 
    579580    if (!h) { /* someone forces me to close dirp */ 
    580581        if (dirp) { 
     
    586587        dp = 0; 
    587588        return 1; 
    588589    } 
     590     
     591    if (!(case_sense->state & C_BOOL)) 
     592        flags |= REG_ICASE; 
     593         
    589594 do_search_begin: 
    590595    while (!dp){ 
    591596         
     
    662667        g_free (tmp_name); 
    663668    } 
    664669 
    665     if (regexp_match (find_pattern, dp->d_name, match_file)){ 
     670    if (regexp_match (find_pattern, dp->d_name, match_file, flags)){ 
    666671        if (content_pattern) { 
    667672            if (search_content (h, directory, dp->d_name)) { 
    668673                return 1; 
  • src/user.c

    diff -Naur mc-4.6.1.orig/src/user.c mc-4.6.1/src/user.c
    old new  
    412412            break; 
    413413        case 'f': /* file name pattern */ 
    414414            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); 
    416416            break; 
    417417        case 'y': /* syntax pattern */ 
    418418            if (edit_widget && edit_widget->syntax_type) { 
    419419                p = extract_arg (p, arg, sizeof (arg)); 
    420420                *condition = panel && 
    421                     regexp_match (arg, edit_widget->syntax_type, match_normal); 
     421                    regexp_match (arg, edit_widget->syntax_type, match_normal, 0); 
    422422            } 
    423423            break; 
    424424        case 'd': 
    425425            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); 
    427427            break; 
    428428        case 't': 
    429429            p = extract_arg (p, arg, sizeof (arg)); 
  • src/util.c

    diff -Naur mc-4.6.1.orig/src/util.c mc-4.6.1/src/util.c
    old new  
    563563        return  g_strdup (pattern); 
    564564} 
    565565 
    566 int regexp_match (const char *pattern, const char *string, int match_type) 
     566int regexp_match (const char *pattern, const char *string, int match_type, int flags) 
    567567{ 
    568568    static regex_t r; 
    569569    static char *old_pattern = NULL; 
    570570    static int old_type; 
     571    static int old_flags; 
    571572    int    rval; 
    572573    char *my_pattern; 
    573574 
    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){ 
    575576        if (old_pattern){ 
    576577            regfree (&r); 
    577578            g_free (old_pattern); 
    578579            old_pattern = NULL; 
    579580        } 
    580581        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)) { 
    582584            g_free (my_pattern); 
    583585            return -1; 
    584586        } 
    585587        old_pattern = my_pattern; 
    586588        old_type = match_type; 
     589        old_flags = flags; 
    587590    } 
    588591    rval = !regexec (&r, string, 0, NULL, 0); 
    589592    return rval; 
  • src/util.h

    diff -Naur mc-4.6.1.orig/src/util.h mc-4.6.1/src/util.h
    old new  
    116116 
    117117extern int easy_patterns; 
    118118char *convert_pattern (const char *pattern, int match_type, int do_group); 
    119 int regexp_match (const char *pattern, const char *string, int match_type); 
     119int regexp_match (const char *pattern, const char *string, int match_type, int flags); 
    120120 
    121121/* Error pipes */ 
    122122void open_error_pipe (void);