From 0b0f7e3975c559ff696a0175c7b7c89c1a8091d2 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Mon, 9 Sep 2013 15:55:01 +0300 Subject: [PATCH] Refactoring: use define DEFAULT_CHARSET for "ASCII" charset. Signed-off-by: Slava Zanko --- lib/charsets.c | 2 +- lib/filehighlight/ini-file-read.c | 4 ++-- lib/global.h | 2 ++ lib/strutil/strutil.c | 2 +- src/editor/syntax.c | 4 ++-- src/filemanager/ext.c | 6 +++--- src/filemanager/usermenu.c | 11 ++++++----- src/vfs/sftpfs/config_parcer.c | 6 +++--- 8 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/charsets.c b/lib/charsets.c index 63583a4dc..3fee23ab2 100644 --- a/lib/charsets.c +++ b/lib/charsets.c @@ -220,7 +220,7 @@ load_codepages_list (void) fprintf (stderr, "%s\n", _("Warning: cannot load codepages list")); codepages = g_ptr_array_new (); - g_ptr_array_add (codepages, new_codepage_desc ("ASCII", _("7-bit ASCII"))); + g_ptr_array_add (codepages, new_codepage_desc (DEFAULT_CHARSET, _("7-bit ASCII"))); } } diff --git a/lib/filehighlight/ini-file-read.c b/lib/filehighlight/ini-file-read.c index 78d235089..8b5901c93 100644 --- a/lib/filehighlight/ini-file-read.c +++ b/lib/filehighlight/ini-file-read.c @@ -115,7 +115,7 @@ mc_fhl_parse_get_regexp (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 (regexp, -1, "ASCII"); + mc_filter->search_condition = mc_search_new (regexp, -1, DEFAULT_CHARSET); mc_filter->search_condition->is_case_sensitive = TRUE; mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX; @@ -162,7 +162,7 @@ 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, buf->len, "ASCII"); + mc_filter->search_condition = mc_search_new (buf->str, buf->len, DEFAULT_CHARSET); mc_filter->search_condition->is_case_sensitive = mc_config_get_bool (fhl->config, group_name, "extensions_case", TRUE); mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX; diff --git a/lib/global.h b/lib/global.h index 03c6ab90d..218fff5ff 100644 --- a/lib/global.h +++ b/lib/global.h @@ -155,6 +155,8 @@ #define MC_ERROR g_quark_from_static_string (PACKAGE) +#define DEFAULT_CHARSET "ASCII" + /*** enums ***************************************************************************************/ /* run mode and params */ diff --git a/lib/strutil/strutil.c b/lib/strutil/strutil.c index 9e51f3187..184fa86f7 100644 --- a/lib/strutil/strutil.c +++ b/lib/strutil/strutil.c @@ -370,7 +370,7 @@ str_init_strings (const char *termenc) if (str_cnv_not_convert == INVALID_CONV) { g_free (codeset); - codeset = g_strdup ("ASCII"); + codeset = g_strdup (DEFAULT_CHARSET); str_cnv_not_convert = g_iconv_open (codeset, codeset); } } diff --git a/src/editor/syntax.c b/src/editor/syntax.c index e23095718..eca575847 100644 --- a/src/editor/syntax.c +++ b/src/editor/syntax.c @@ -1314,12 +1314,12 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file, /* 3: auto-detect rule set from regular expressions */ int q; - q = mc_search (args[1], "ASCII", editor_file, MC_SEARCH_T_REGEX); + q = mc_search (args[1], DEFAULT_CHARSET, editor_file, MC_SEARCH_T_REGEX); /* does filename match arg 1 ? */ if (!q && args[3]) { /* does first line match arg 3 ? */ - q = mc_search (args[3], "ASCII", first_line, MC_SEARCH_T_REGEX); + q = mc_search (args[3], DEFAULT_CHARSET, first_line, MC_SEARCH_T_REGEX); } if (q) { diff --git a/src/filemanager/ext.c b/src/filemanager/ext.c index 428a628d0..58862216a 100644 --- a/src/filemanager/ext.c +++ b/src/filemanager/ext.c @@ -726,7 +726,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, gboolean c { mc_search_t *search; - search = mc_search_new (ptr, -1, "ASCII"); + search = mc_search_new (ptr, -1, DEFAULT_CHARSET); if (search != NULL) { search->search_type = MC_SEARCH_T_REGEX; @@ -917,7 +917,7 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char * if (case_insense) p += 2; - search = mc_search_new (p, -1, "ASCII"); + search = mc_search_new (p, -1, DEFAULT_CHARSET); if (search != NULL) { search->search_type = MC_SEARCH_T_REGEX; @@ -930,7 +930,7 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char * else if (strncmp (p, "directory/", 10) == 0) { if (S_ISDIR (mystat.st_mode) - && mc_search (p + 10, "ASCII", vfs_path_as_str (filename_vpath), + && mc_search (p + 10, DEFAULT_CHARSET, vfs_path_as_str (filename_vpath), MC_SEARCH_T_REGEX)) found = TRUE; } diff --git a/src/filemanager/usermenu.c b/src/filemanager/usermenu.c index 945cfc48f..bafb1a752 100644 --- a/src/filemanager/usermenu.c +++ b/src/filemanager/usermenu.c @@ -247,13 +247,13 @@ test_condition (WEdit * edit_widget, char *p, int *condition) char *edit_filename; edit_filename = edit_get_file_name (edit_widget); - *condition = mc_search (arg, "ASCII", edit_filename, search_type) ? 1 : 0; + *condition = mc_search (arg, DEFAULT_CHARSET, edit_filename, search_type) ? 1 : 0; g_free (edit_filename); } else #endif *condition = panel != NULL && - mc_search (arg, "ASCII", panel->dir.list[panel->selected].fname, + mc_search (arg, DEFAULT_CHARSET, panel->dir.list[panel->selected].fname, search_type) ? 1 : 0; break; case 'y': /* syntax pattern */ @@ -264,7 +264,8 @@ test_condition (WEdit * edit_widget, char *p, int *condition) if (syntax_type != NULL) { p = extract_arg (p, arg, sizeof (arg)); - *condition = mc_search (arg, "ASCII", syntax_type, MC_SEARCH_T_NORMAL) ? 1 : 0; + *condition = + mc_search (arg, DEFAULT_CHARSET, syntax_type, MC_SEARCH_T_NORMAL) ? 1 : 0; } } #endif @@ -272,7 +273,7 @@ test_condition (WEdit * edit_widget, char *p, int *condition) case 'd': p = extract_arg (p, arg, sizeof (arg)); *condition = panel != NULL - && mc_search (arg, "ASCII", vfs_path_as_str (panel->cwd_vpath), + && mc_search (arg, DEFAULT_CHARSET, vfs_path_as_str (panel->cwd_vpath), search_type) ? 1 : 0; break; case 't': @@ -641,7 +642,7 @@ check_format_view (const char *p) { for (q++; *q && *q != '}'; q++) { - if (!strncmp (q, "ascii", 5)) + if (!strncmp (q, DEFAULT_CHARSET, 5)) { mcview_default_hex_mode = 0; q += 4; diff --git a/src/vfs/sftpfs/config_parcer.c b/src/vfs/sftpfs/config_parcer.c index 16efb373a..303306c36 100644 --- a/src/vfs/sftpfs/config_parcer.c +++ b/src/vfs/sftpfs/config_parcer.c @@ -210,7 +210,7 @@ sftpfs_fill_config_entity_from_config (FILE * ssh_config_handler, gboolean pattern_block_hit = FALSE; mc_search_t *host_regexp; - host_regexp = mc_search_new ("^\\s*host\\s+(.*)$", -1, "ASCII"); + host_regexp = mc_search_new ("^\\s*host\\s+(.*)$", -1, DEFAULT_CHARSET); host_regexp->search_type = MC_SEARCH_T_REGEX; host_regexp->is_case_sensitive = FALSE; @@ -254,7 +254,7 @@ sftpfs_fill_config_entity_from_config (FILE * ssh_config_handler, mc_search_t *pattern_regexp; pattern_block_hit = FALSE; - pattern_regexp = mc_search_new (host_pattern, -1, "ASCII"); + pattern_regexp = mc_search_new (host_pattern, -1, DEFAULT_CHARSET); pattern_regexp->search_type = MC_SEARCH_T_GLOB; pattern_regexp->is_case_sensitive = FALSE; pattern_regexp->is_entire_line = TRUE; @@ -398,7 +398,7 @@ sftpfs_init_config_variables_patterns (void) for (i = 0; config_variables[i].pattern != NULL; i++) { config_variables[i].pattern_regexp = - mc_search_new (config_variables[i].pattern, -1, "ASCII"); + mc_search_new (config_variables[i].pattern, -1, DEFAULT_CHARSET); config_variables[i].pattern_regexp->search_type = MC_SEARCH_T_REGEX; config_variables[i].pattern_regexp->is_case_sensitive = FALSE; config_variables[i].offset = structure_offsets[i];