Ticket #2309: glob-to-regex.patch

File glob-to-regex.patch, 1.7 KB (added by boris, 9 years ago)
  • lib/search/glob.c

    a b  
    5555 
    5656    buff = g_string_sized_new (32); 
    5757 
    58     for (loop = 0; loop < astr->len; loop++) 
     58    for (loop = 0; loop < astr->len; loop++) { 
    5959        switch (str[loop]) 
    6060        { 
    6161        case '*': 
    6262            if (!strutils_is_char_escaped (str, &(str[loop]))) 
     63            { 
    6364                g_string_append (buff, inside_group ? ".*" : "(.*)"); 
     65                continue; 
     66            } 
    6467            break; 
    6568        case '?': 
    6669            if (!strutils_is_char_escaped (str, &(str[loop]))) 
     70            { 
    6771                g_string_append (buff, inside_group ? "." : "(.)"); 
     72                continue; 
     73            } 
    6874            break; 
    6975        case ',': 
    7076            if (!strutils_is_char_escaped (str, &(str[loop]))) 
    71                 g_string_append_c (buff, '|'); 
     77            { 
     78                g_string_append_c (buff, inside_group ? '|' : ','); 
     79                continue; 
     80            } 
    7281            break; 
    7382        case '{': 
    7483            if (!strutils_is_char_escaped (str, &(str[loop]))) 
    7584            { 
    7685                g_string_append_c (buff, '('); 
    7786                inside_group = TRUE; 
     87                continue; 
    7888            } 
    7989            break; 
    8090        case '}': 
     
    8292            { 
    8393                g_string_append_c (buff, ')'); 
    8494                inside_group = FALSE; 
     95                continue; 
    8596            } 
    8697            break; 
    8798        case '+': 
     
    91102        case ')': 
    92103        case '^': 
    93104            g_string_append_c (buff, '\\'); 
    94             /* fall through */ 
    95         default: 
    96             g_string_append_c (buff, str[loop]); 
    97             break; 
    98105        } 
    99  
     106        g_string_append_c (buff, str[loop]); 
     107    } 
    100108    return buff; 
    101109} 
    102110