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 55 55 56 56 buff = g_string_sized_new (32); 57 57 58 for (loop = 0; loop < astr->len; loop++) 58 for (loop = 0; loop < astr->len; loop++) { 59 59 switch (str[loop]) 60 60 { 61 61 case '*': 62 62 if (!strutils_is_char_escaped (str, &(str[loop]))) 63 { 63 64 g_string_append (buff, inside_group ? ".*" : "(.*)"); 65 continue; 66 } 64 67 break; 65 68 case '?': 66 69 if (!strutils_is_char_escaped (str, &(str[loop]))) 70 { 67 71 g_string_append (buff, inside_group ? "." : "(.)"); 72 continue; 73 } 68 74 break; 69 75 case ',': 70 76 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 } 72 81 break; 73 82 case '{': 74 83 if (!strutils_is_char_escaped (str, &(str[loop]))) 75 84 { 76 85 g_string_append_c (buff, '('); 77 86 inside_group = TRUE; 87 continue; 78 88 } 79 89 break; 80 90 case '}': … … 82 92 { 83 93 g_string_append_c (buff, ')'); 84 94 inside_group = FALSE; 95 continue; 85 96 } 86 97 break; 87 98 case '+': … … 91 102 case ')': 92 103 case '^': 93 104 g_string_append_c (buff, '\\'); 94 /* fall through */95 default:96 g_string_append_c (buff, str[loop]);97 break;98 105 } 99 106 g_string_append_c (buff, str[loop]); 107 } 100 108 return buff; 101 109 } 102 110