diff --git a/lib/search/regex.c b/lib/search/regex.c
index 4ee3979..082fa2c 100644
a
|
b
|
typedef enum |
61 | 61 | |
62 | 62 | /*** file scope functions ************************************************************************/ |
63 | 63 | |
| 64 | #ifndef SEARCH_TYPE_GLIB |
64 | 65 | static gboolean |
65 | 66 | mc_search__regex_str_append_if_special (GString * copy_to, const GString * regex_str, |
66 | 67 | gsize * offset) |
… |
… |
mc_search__cond_struct_new_regex_ci_str (const char *charset, const GString * as |
244 | 245 | |
245 | 246 | return ret_str; |
246 | 247 | } |
| 248 | #endif /* !SEARCH_TYPE_GLIB */ |
247 | 249 | |
248 | 250 | /* --------------------------------------------------------------------------------------------- */ |
249 | 251 | |
… |
… |
mc_search_regex__process_escape_sequence (GString * dest_str, const char *from, |
717 | 719 | */ |
718 | 720 | |
719 | 721 | static GRegexCompileFlags |
720 | | mc_search__regex_get_compile_flags (const char *charset) |
| 722 | mc_search__regex_get_compile_flags (const char *charset, gboolean is_case_sensitive) |
721 | 723 | { |
722 | 724 | GRegexCompileFlags g_regex_options = G_REGEX_OPTIMIZE | G_REGEX_DOTALL; |
723 | 725 | |
724 | 726 | if (!(mc_global.utf8_display && str_isutf8 (charset))) |
725 | 727 | g_regex_options |= G_REGEX_RAW; |
726 | 728 | |
| 729 | if (!is_case_sensitive) |
| 730 | g_regex_options |= G_REGEX_CASELESS; |
| 731 | |
727 | 732 | return g_regex_options; |
728 | 733 | } |
729 | 734 | |
… |
… |
mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * lc_mc_ |
738 | 743 | #ifdef SEARCH_TYPE_GLIB |
739 | 744 | GError *mcerror = NULL; |
740 | 745 | |
741 | | if (!lc_mc_search->is_case_sensitive) |
742 | | { |
743 | | GString *tmp; |
744 | | |
745 | | tmp = mc_search_cond->str; |
746 | | mc_search_cond->str = mc_search__cond_struct_new_regex_ci_str (charset, tmp); |
747 | | g_string_free (tmp, TRUE); |
748 | | } |
749 | 746 | mc_search_cond->regex_handle = |
750 | | g_regex_new (mc_search_cond->str->str, mc_search__regex_get_compile_flags (charset), 0, |
751 | | &mcerror); |
| 747 | g_regex_new (mc_search_cond->str->str, |
| 748 | mc_search__regex_get_compile_flags (charset, lc_mc_search->is_case_sensitive), |
| 749 | 0, &mcerror); |
752 | 750 | |
753 | 751 | if (mcerror != NULL) |
754 | 752 | { |
diff --git a/tests/lib/search/regex_get_compile_flags.c b/tests/lib/search/regex_get_compile_flags.c
index 9d22e1e..94257d9 100644
a
|
b
|
static const struct test_regex_get_compile_flags_ds |
37 | 37 | { |
38 | 38 | const char *charset; |
39 | 39 | const gboolean utf_flag; |
| 40 | const gboolean is_case_sensitive; |
40 | 41 | const GRegexCompileFlags expected_result; |
41 | 42 | } test_regex_get_compile_flags_ds[] = |
42 | 43 | { |
43 | 44 | { |
44 | 45 | "utf8", |
45 | 46 | TRUE, |
| 47 | TRUE, |
46 | 48 | G_REGEX_OPTIMIZE | G_REGEX_DOTALL |
47 | 49 | }, |
48 | 50 | { |
49 | 51 | "utf8", |
50 | 52 | FALSE, |
| 53 | TRUE, |
51 | 54 | G_REGEX_OPTIMIZE | G_REGEX_DOTALL | G_REGEX_RAW |
52 | 55 | }, |
53 | 56 | { |
| 57 | "utf8", |
| 58 | TRUE, |
| 59 | FALSE, |
| 60 | G_REGEX_OPTIMIZE | G_REGEX_DOTALL | G_REGEX_CASELESS |
| 61 | }, |
| 62 | { |
| 63 | "utf8", |
| 64 | FALSE, |
| 65 | FALSE, |
| 66 | G_REGEX_OPTIMIZE | G_REGEX_DOTALL | G_REGEX_RAW | G_REGEX_CASELESS |
| 67 | }, |
| 68 | { |
54 | 69 | "utf-8", |
55 | 70 | TRUE, |
| 71 | TRUE, |
56 | 72 | G_REGEX_OPTIMIZE | G_REGEX_DOTALL |
57 | 73 | }, |
58 | 74 | { |
59 | 75 | "utf-8", |
60 | 76 | FALSE, |
| 77 | TRUE, |
61 | 78 | G_REGEX_OPTIMIZE | G_REGEX_DOTALL | G_REGEX_RAW |
62 | 79 | }, |
63 | 80 | { |
| 81 | "utf-8", |
| 82 | TRUE, |
| 83 | FALSE, |
| 84 | G_REGEX_OPTIMIZE | G_REGEX_DOTALL | G_REGEX_CASELESS |
| 85 | }, |
| 86 | { |
| 87 | "utf-8", |
| 88 | FALSE, |
| 89 | FALSE, |
| 90 | G_REGEX_OPTIMIZE | G_REGEX_DOTALL | G_REGEX_RAW | G_REGEX_CASELESS |
| 91 | }, |
| 92 | { |
64 | 93 | "latin1", |
65 | 94 | TRUE, |
| 95 | TRUE, |
66 | 96 | G_REGEX_OPTIMIZE | G_REGEX_DOTALL | G_REGEX_RAW |
67 | 97 | }, |
68 | 98 | { |
69 | 99 | "latin1", |
70 | 100 | FALSE, |
| 101 | TRUE, |
71 | 102 | G_REGEX_OPTIMIZE | G_REGEX_DOTALL | G_REGEX_RAW |
72 | 103 | }, |
73 | 104 | { |
74 | 105 | "blablabla", |
75 | 106 | TRUE, |
| 107 | TRUE, |
76 | 108 | G_REGEX_OPTIMIZE | G_REGEX_DOTALL | G_REGEX_RAW |
77 | 109 | }, |
78 | 110 | }; |
… |
… |
START_PARAMETRIZED_TEST (test_regex_get_compile_flags, test_regex_get_compile_fl |
89 | 121 | mc_global.utf8_display = data->utf_flag; |
90 | 122 | |
91 | 123 | /* when */ |
92 | | actual_result = mc_search__regex_get_compile_flags (data->charset); |
| 124 | actual_result = mc_search__regex_get_compile_flags (data->charset, data->is_case_sensitive); |
93 | 125 | |
94 | 126 | /* then */ |
95 | 127 | mctest_assert_int_eq (actual_result, data->expected_result); |