Refactoring: use define DEFAULT_CHARSET for "ASCII" charset.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2013-09-09 15:55:01 +03:00 committed by Andrew Borodin
parent 941a1eac1d
commit 0b0f7e3975
8 changed files with 20 additions and 17 deletions

View File

@ -220,7 +220,7 @@ load_codepages_list (void)
fprintf (stderr, "%s\n", _("Warning: cannot load codepages list")); fprintf (stderr, "%s\n", _("Warning: cannot load codepages list"));
codepages = g_ptr_array_new (); 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")));
} }
} }

View File

@ -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 = g_new0 (mc_fhl_filter_t, 1);
mc_filter->type = MC_FLHGH_T_FREGEXP; 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->is_case_sensitive = TRUE;
mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX; 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 = g_new0 (mc_fhl_filter_t, 1);
mc_filter->type = MC_FLHGH_T_FREGEXP; 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_filter->search_condition->is_case_sensitive =
mc_config_get_bool (fhl->config, group_name, "extensions_case", TRUE); mc_config_get_bool (fhl->config, group_name, "extensions_case", TRUE);
mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX; mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX;

View File

@ -155,6 +155,8 @@
#define MC_ERROR g_quark_from_static_string (PACKAGE) #define MC_ERROR g_quark_from_static_string (PACKAGE)
#define DEFAULT_CHARSET "ASCII"
/*** enums ***************************************************************************************/ /*** enums ***************************************************************************************/
/* run mode and params */ /* run mode and params */

View File

@ -370,7 +370,7 @@ str_init_strings (const char *termenc)
if (str_cnv_not_convert == INVALID_CONV) if (str_cnv_not_convert == INVALID_CONV)
{ {
g_free (codeset); g_free (codeset);
codeset = g_strdup ("ASCII"); codeset = g_strdup (DEFAULT_CHARSET);
str_cnv_not_convert = g_iconv_open (codeset, codeset); str_cnv_not_convert = g_iconv_open (codeset, codeset);
} }
} }

View File

@ -1314,12 +1314,12 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
/* 3: auto-detect rule set from regular expressions */ /* 3: auto-detect rule set from regular expressions */
int q; 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 ? */ /* does filename match arg 1 ? */
if (!q && args[3]) if (!q && args[3])
{ {
/* does first line match arg 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) if (q)
{ {

View File

@ -726,7 +726,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, gboolean c
{ {
mc_search_t *search; mc_search_t *search;
search = mc_search_new (ptr, -1, "ASCII"); search = mc_search_new (ptr, -1, DEFAULT_CHARSET);
if (search != NULL) if (search != NULL)
{ {
search->search_type = MC_SEARCH_T_REGEX; 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) if (case_insense)
p += 2; p += 2;
search = mc_search_new (p, -1, "ASCII"); search = mc_search_new (p, -1, DEFAULT_CHARSET);
if (search != NULL) if (search != NULL)
{ {
search->search_type = MC_SEARCH_T_REGEX; 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) else if (strncmp (p, "directory/", 10) == 0)
{ {
if (S_ISDIR (mystat.st_mode) 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)) MC_SEARCH_T_REGEX))
found = TRUE; found = TRUE;
} }

View File

@ -247,13 +247,13 @@ test_condition (WEdit * edit_widget, char *p, int *condition)
char *edit_filename; char *edit_filename;
edit_filename = edit_get_file_name (edit_widget); 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); g_free (edit_filename);
} }
else else
#endif #endif
*condition = panel != NULL && *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; search_type) ? 1 : 0;
break; break;
case 'y': /* syntax pattern */ case 'y': /* syntax pattern */
@ -264,7 +264,8 @@ test_condition (WEdit * edit_widget, char *p, int *condition)
if (syntax_type != NULL) if (syntax_type != NULL)
{ {
p = extract_arg (p, arg, sizeof (arg)); 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 #endif
@ -272,7 +273,7 @@ test_condition (WEdit * edit_widget, char *p, int *condition)
case 'd': case 'd':
p = extract_arg (p, arg, sizeof (arg)); p = extract_arg (p, arg, sizeof (arg));
*condition = panel != NULL *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; search_type) ? 1 : 0;
break; break;
case 't': case 't':
@ -641,7 +642,7 @@ check_format_view (const char *p)
{ {
for (q++; *q && *q != '}'; q++) for (q++; *q && *q != '}'; q++)
{ {
if (!strncmp (q, "ascii", 5)) if (!strncmp (q, DEFAULT_CHARSET, 5))
{ {
mcview_default_hex_mode = 0; mcview_default_hex_mode = 0;
q += 4; q += 4;

View File

@ -210,7 +210,7 @@ sftpfs_fill_config_entity_from_config (FILE * ssh_config_handler,
gboolean pattern_block_hit = FALSE; gboolean pattern_block_hit = FALSE;
mc_search_t *host_regexp; 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->search_type = MC_SEARCH_T_REGEX;
host_regexp->is_case_sensitive = FALSE; 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; mc_search_t *pattern_regexp;
pattern_block_hit = FALSE; 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->search_type = MC_SEARCH_T_GLOB;
pattern_regexp->is_case_sensitive = FALSE; pattern_regexp->is_case_sensitive = FALSE;
pattern_regexp->is_entire_line = TRUE; 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++) for (i = 0; config_variables[i].pattern != NULL; i++)
{ {
config_variables[i].pattern_regexp = 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->search_type = MC_SEARCH_T_REGEX;
config_variables[i].pattern_regexp->is_case_sensitive = FALSE; config_variables[i].pattern_regexp->is_case_sensitive = FALSE;
config_variables[i].offset = structure_offsets[i]; config_variables[i].offset = structure_offsets[i];