From 71642b9bdbdced728ed056ffeaba3907a2870eb1 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Sat, 3 Oct 2009 00:26:27 +0300 Subject: [PATCH] Ticket #1620: File hightlighting based on extension is case sensitive. Added parameter extensions_case. Signed-off-by: Slava Zanko --- doc/man/mc.1.in | 4 ++++ doc/man/ru/mc.1.in | 4 ++++ misc/filehighlight.ini | 4 ++-- src/filehighlight/ini-file-read.c | 16 +++++++++------- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/doc/man/mc.1.in b/doc/man/mc.1.in index 55be28ea2..f78d9cc3b 100644 --- a/doc/man/mc.1.in +++ b/doc/man/mc.1.in @@ -3585,6 +3585,10 @@ regular expression. If present, 'extensions' option ignored .TP .I extensions list of extensions of files. Separated by ';' sign. +.TP +.I extensions_case +(make sense only with 'extensions' parameter) make 'extensions' +rule case sentitive (true) or not (false). .PP 'type' key may have values: .nf diff --git a/doc/man/ru/mc.1.in b/doc/man/ru/mc.1.in index 1ee295a87..83842beec 100644 --- a/doc/man/ru/mc.1.in +++ b/doc/man/ru/mc.1.in @@ -3902,6 +3902,10 @@ base_color=normal=white,default:marked=magenta,default .TP .I extensions Список расширений файлов. Раасширения разделяются символом ';'. +.TP +.I extensions_case +(имеет смысл только с параметром 'extensions') делает правило 'extensions' +чувствительным к регистру букв (true) или не чувтсвительным (false). .PP Параметр 'type' (тип файла) может принимать значения: .nf diff --git a/misc/filehighlight.ini b/misc/filehighlight.ini index 0a08067af..6d576dfa8 100644 --- a/misc/filehighlight.ini +++ b/misc/filehighlight.ini @@ -10,7 +10,6 @@ [symlink] type=SYMLINK - [device] type=DEVICE @@ -22,7 +21,8 @@ [temp] extensions=tmp;$$$;~;bak - regexp=^#.* + extensions_case=false + regexp=(^#.*|.*~$) [archive] extensions=gz;bz2;tar;tgz;rpm;Z;rar;zip;arj;cab;lzh;lha;zoo;arc;ark;xz;tbz;tbz2; diff --git a/src/filehighlight/ini-file-read.c b/src/filehighlight/ini-file-read.c index bf3572841..8d0a82486 100644 --- a/src/filehighlight/ini-file-read.c +++ b/src/filehighlight/ini-file-read.c @@ -52,7 +52,7 @@ static void mc_fhl_parse_fill_color_info (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, const gchar * group_name) { (void) fhl; - mc_filter->color_pair_index = mc_skin_color_get("filehighlight", group_name); + mc_filter->color_pair_index = mc_skin_color_get ("filehighlight", group_name); } /* --------------------------------------------------------------------------------------------- */ @@ -162,7 +162,8 @@ mc_fhl_parse_get_extensions (mc_fhl_t * fhl, const gchar * group_name) mc_filter = g_new0 (mc_fhl_filter_t, 1); mc_filter->type = MC_FLHGH_T_FREGEXP; mc_filter->search_condition = mc_search_new (buf->str, -1); - mc_filter->search_condition->is_case_sentitive = TRUE; + mc_filter->search_condition->is_case_sentitive = + mc_config_get_bool (fhl->config, group_name, "extensions_case", TRUE); mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX; mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name); @@ -247,21 +248,22 @@ mc_fhl_parse_ini_file (mc_fhl_t * fhl) mc_fhl_array_free (fhl); fhl->filters = g_ptr_array_new (); - orig_group_names = group_names = - mc_config_get_groups (fhl->config, &ftype_names_size); + orig_group_names = group_names = mc_config_get_groups (fhl->config, &ftype_names_size); if (group_names == NULL) - return FALSE; + return FALSE; while (*group_names) { if (mc_config_has_param (fhl->config, *group_names, "type")) { /* parse filetype filter */ mc_fhl_parse_get_file_type_id (fhl, *group_names); - } else if (mc_config_has_param (fhl->config, *group_names, "regexp")) { + } + if (mc_config_has_param (fhl->config, *group_names, "regexp")) { /* parse regexp filter */ mc_fhl_parse_get_regexp (fhl, *group_names); - } else if (mc_config_has_param (fhl->config, *group_names, "extensions")) { + } + if (mc_config_has_param (fhl->config, *group_names, "extensions")) { /* parse extensions filter */ mc_fhl_parse_get_extensions (fhl, *group_names); }