Ticket #56: 11-case-sensitive-find-fix-4.6.1.patch

File 11-case-sensitive-find-fix-4.6.1.patch, 6.0 KB (added by slavazanko, 15 years ago)

added by krix

  • src/cmd.c

    Description: Fixes case-sensitive bug in find dialog
    Status to upstream: Not know, need info, need view CVS
    Source URL and bug desc.: http://www.freebsd.org/cgi/query-pr.cgi?pr=99428
    
    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 cflags = 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_sensitive == 0) 
     592        cflags |= REG_ICASE; 
    589593 do_search_begin: 
    590594    while (!dp){ 
    591595         
     
    662666        g_free (tmp_name); 
    663667    } 
    664668 
    665     if (regexp_match (find_pattern, dp->d_name, match_file)){ 
     669    if (regexp_match (find_pattern, dp->d_name, match_file, cflags)){ 
    666670        if (content_pattern) { 
    667671            if (search_content (h, directory, dp->d_name)) { 
    668672                return 1; 
  • src/subshell.c

    diff -Naur mc-4.6.1.orig/src/subshell.c mc-4.6.1/src/subshell.c
    old new  
    371371            subshell_type = ZSH; 
    372372        else if (strstr (shell, "/tcsh")) 
    373373            subshell_type = TCSH; 
     374        else if (strstr (shell, "/csh")) 
     375            subshell_type = TCSH; 
    374376        else if (strstr (shell, "/bash") || getenv ("BASH")) 
    375377            subshell_type = BASH; 
    376378        else { 
  • 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 cflags) 
    567567{ 
    568568    static regex_t r; 
    569569    static char *old_pattern = NULL; 
    570570    static int old_type; 
     571        static int old_cflags; 
    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) ||  
     576                old_type != match_type || cflags != old_cflags){ 
    575577        if (old_pattern){ 
    576578            regfree (&r); 
    577579            g_free (old_pattern); 
    578580            old_pattern = NULL; 
    579581        } 
    580582        my_pattern = convert_pattern (pattern, match_type, 0); 
    581         if (regcomp (&r, my_pattern, REG_EXTENDED|REG_NOSUB|MC_ARCH_FLAGS)) { 
     583        if (regcomp (&r, my_pattern, REG_EXTENDED|REG_NOSUB|MC_ARCH_FLAGS|cflags)) { 
    582584            g_free (my_pattern); 
    583585            return -1; 
    584586        } 
     587        old_cflags = cflags; 
    585588        old_pattern = my_pattern; 
    586589        old_type = match_type; 
    587590    } 
  • 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 cflags); 
    120120 
    121121/* Error pipes */ 
    122122void open_error_pipe (void);