mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-22 03:02:06 +03:00
Fix -Wconversion warning for mc_search_new().
mc_search_new() parameter orignial_len use once only. Factor out into own function mc_search_new_len(). Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
646b662eb0
commit
5007d309bc
@ -113,7 +113,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, DEFAULT_CHARSET);
|
||||
mc_filter->search_condition = mc_search_new (regexp, DEFAULT_CHARSET);
|
||||
mc_filter->search_condition->is_case_sensitive = TRUE;
|
||||
mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX;
|
||||
|
||||
@ -158,7 +158,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, DEFAULT_CHARSET);
|
||||
mc_filter->search_condition = mc_search_new_len (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;
|
||||
|
@ -129,8 +129,10 @@ typedef struct mc_search_type_str_struct
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
mc_search_t *mc_search_new (const gchar * original, gsize original_len,
|
||||
const gchar * original_charset);
|
||||
mc_search_t *mc_search_new (const gchar * original, const gchar * original_charset);
|
||||
|
||||
mc_search_t *mc_search_new_len (const gchar * original, gsize original_len,
|
||||
const gchar * original_charset);
|
||||
|
||||
void mc_search_free (mc_search_t * lc_mc_search);
|
||||
|
||||
|
@ -123,6 +123,24 @@ mc_search__conditions_free (GPtrArray * array)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* Init search descriptor.
|
||||
*
|
||||
* @param original pattern to search
|
||||
* @param original_charset charset of #original. If NULL then cp_display will be used
|
||||
*
|
||||
* @return new mc_search_t object. Use #mc_search_free() to free it.
|
||||
*/
|
||||
|
||||
mc_search_t *
|
||||
mc_search_new (const gchar * original, const gchar * original_charset)
|
||||
{
|
||||
if (original == NULL)
|
||||
return NULL;
|
||||
|
||||
return mc_search_new_len (original, strlen (original), original_charset);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* Init search descriptor.
|
||||
*
|
||||
@ -134,20 +152,13 @@ mc_search__conditions_free (GPtrArray * array)
|
||||
*/
|
||||
|
||||
mc_search_t *
|
||||
mc_search_new (const gchar * original, gsize original_len, const gchar * original_charset)
|
||||
mc_search_new_len (const gchar * original, gsize original_len, const gchar * original_charset)
|
||||
{
|
||||
mc_search_t *lc_mc_search;
|
||||
|
||||
if (original == NULL)
|
||||
if (original == NULL || original_len == 0)
|
||||
return NULL;
|
||||
|
||||
if ((gssize) original_len == -1)
|
||||
{
|
||||
original_len = strlen (original);
|
||||
if (original_len == 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lc_mc_search = g_new0 (mc_search_t, 1);
|
||||
lc_mc_search->original = g_strndup (original, original_len);
|
||||
lc_mc_search->original_len = original_len;
|
||||
@ -415,7 +426,7 @@ mc_search (const gchar * pattern, const gchar * pattern_charset, const gchar * s
|
||||
if (str == NULL)
|
||||
return FALSE;
|
||||
|
||||
search = mc_search_new (pattern, -1, pattern_charset);
|
||||
search = mc_search_new (pattern, pattern_charset);
|
||||
if (search == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -251,9 +251,9 @@ dview_search_cmd (WDiff * dview)
|
||||
|
||||
mc_search_free (dview->search.handle);
|
||||
#ifdef HAVE_CHARSET
|
||||
dview->search.handle = mc_search_new (dview->search.last_string, -1, cp_source);
|
||||
dview->search.handle = mc_search_new (dview->search.last_string, cp_source);
|
||||
#else
|
||||
dview->search.handle = mc_search_new (dview->search.last_string, -1, NULL);
|
||||
dview->search.handle = mc_search_new (dview->search.last_string, NULL);
|
||||
#endif
|
||||
|
||||
if (dview->search.handle == NULL)
|
||||
|
@ -1226,9 +1226,9 @@ edit_collect_completions (WEdit * edit, off_t word_start, gsize word_len,
|
||||
edit_search_status_msg_t esm;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
srch = mc_search_new (match_expr, -1, cp_source);
|
||||
srch = mc_search_new (match_expr, cp_source);
|
||||
#else
|
||||
srch = mc_search_new (match_expr, -1, NULL);
|
||||
srch = mc_search_new (match_expr, NULL);
|
||||
#endif
|
||||
if (srch == NULL)
|
||||
return 0;
|
||||
@ -2567,9 +2567,9 @@ edit_replace_cmd (WEdit * edit, int again)
|
||||
if (edit->search == NULL)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
edit->search = mc_search_new (input1, -1, cp_source);
|
||||
edit->search = mc_search_new (input1, cp_source);
|
||||
#else
|
||||
edit->search = mc_search_new (input1, -1, NULL);
|
||||
edit->search = mc_search_new (input1, NULL);
|
||||
#endif
|
||||
if (edit->search == NULL)
|
||||
{
|
||||
@ -2789,9 +2789,9 @@ edit_search_cmd (WEdit * edit, gboolean again)
|
||||
g_list_free_full (history, g_free);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
edit->search = mc_search_new (edit->last_search_string, -1, cp_source);
|
||||
edit->search = mc_search_new (edit->last_search_string, cp_source);
|
||||
#else
|
||||
edit->search = mc_search_new (edit->last_search_string, -1, NULL);
|
||||
edit->search = mc_search_new (edit->last_search_string, NULL);
|
||||
#endif
|
||||
if (edit->search == NULL)
|
||||
{
|
||||
|
@ -163,9 +163,9 @@ editcmd_dialog_search_show (WEdit * edit)
|
||||
mc_search_free (edit->search);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
edit->search = mc_search_new (edit->last_search_string, -1, cp_source);
|
||||
edit->search = mc_search_new (edit->last_search_string, cp_source);
|
||||
#else
|
||||
edit->search = mc_search_new (edit->last_search_string, -1, NULL);
|
||||
edit->search = mc_search_new (edit->last_search_string, NULL);
|
||||
#endif
|
||||
if (edit->search != NULL)
|
||||
{
|
||||
|
@ -723,7 +723,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, DEFAULT_CHARSET);
|
||||
search = mc_search_new (ptr, DEFAULT_CHARSET);
|
||||
if (search != NULL)
|
||||
{
|
||||
search->search_type = MC_SEARCH_T_REGEX;
|
||||
@ -912,7 +912,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, DEFAULT_CHARSET);
|
||||
search = mc_search_new (p, DEFAULT_CHARSET);
|
||||
if (search != NULL)
|
||||
{
|
||||
search->search_type = MC_SEARCH_T_REGEX;
|
||||
|
@ -1303,7 +1303,7 @@ file_mask_dialog (file_op_context_t * ctx, FileOperation operation,
|
||||
return dest_dir;
|
||||
}
|
||||
|
||||
ctx->search_handle = mc_search_new (source_mask, -1, NULL);
|
||||
ctx->search_handle = mc_search_new (source_mask, NULL);
|
||||
|
||||
if (ctx->search_handle == NULL)
|
||||
{
|
||||
|
@ -403,7 +403,7 @@ find_check_regexp (const char *r)
|
||||
mc_search_t *search;
|
||||
gboolean regexp_ok = FALSE;
|
||||
|
||||
search = mc_search_new (r, -1, NULL);
|
||||
search = mc_search_new (r, NULL);
|
||||
|
||||
if (search != NULL)
|
||||
{
|
||||
@ -1623,7 +1623,7 @@ run_process (void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
search_content_handle = mc_search_new (content_pattern, -1, NULL);
|
||||
search_content_handle = mc_search_new (content_pattern, NULL);
|
||||
if (search_content_handle)
|
||||
{
|
||||
search_content_handle->search_type =
|
||||
@ -1634,7 +1634,7 @@ run_process (void)
|
||||
search_content_handle->is_all_charsets = options.content_all_charsets;
|
||||
#endif
|
||||
}
|
||||
search_file_handle = mc_search_new (find_pattern, -1, NULL);
|
||||
search_file_handle = mc_search_new (find_pattern, NULL);
|
||||
search_file_handle->search_type = options.file_pattern ? MC_SEARCH_T_GLOB : MC_SEARCH_T_REGEX;
|
||||
search_file_handle->is_case_sensitive = options.file_case_sens;
|
||||
#ifdef HAVE_CHARSET
|
||||
|
@ -2056,7 +2056,7 @@ panel_select_ext_cmd (void)
|
||||
|
||||
g_free (cur_file_ext);
|
||||
|
||||
search = mc_search_new (reg_exp, -1, NULL);
|
||||
search = mc_search_new (reg_exp, NULL);
|
||||
search->search_type = MC_SEARCH_T_REGEX;
|
||||
search->is_case_sensitive = FALSE;
|
||||
|
||||
@ -2524,7 +2524,7 @@ panel_select_unselect_files (WPanel * panel, const char *title, const char *hist
|
||||
return;
|
||||
}
|
||||
|
||||
search = mc_search_new (reg_exp, -1, NULL);
|
||||
search = mc_search_new (reg_exp, NULL);
|
||||
search->search_type = (shell_patterns != 0) ? MC_SEARCH_T_GLOB : MC_SEARCH_T_REGEX;
|
||||
search->is_entire_line = TRUE;
|
||||
search->is_case_sensitive = case_sens != 0;
|
||||
@ -2644,7 +2644,7 @@ do_search (WPanel * panel, int c_code)
|
||||
|
||||
reg_exp = g_strdup_printf ("%s*", panel->search_buffer);
|
||||
esc_str = strutils_escape (reg_exp, -1, ",|\\{}[]", TRUE);
|
||||
search = mc_search_new (esc_str, -1, NULL);
|
||||
search = mc_search_new (esc_str, NULL);
|
||||
search->search_type = MC_SEARCH_T_GLOB;
|
||||
search->is_entire_line = TRUE;
|
||||
|
||||
|
@ -213,7 +213,7 @@ sftpfs_fill_config_entity_from_config (FILE * ssh_config_handler,
|
||||
|
||||
mc_return_val_if_error (mcerror, FALSE);
|
||||
|
||||
host_regexp = mc_search_new ("^\\s*host\\s+(.*)$", -1, DEFAULT_CHARSET);
|
||||
host_regexp = mc_search_new ("^\\s*host\\s+(.*)$", DEFAULT_CHARSET);
|
||||
host_regexp->search_type = MC_SEARCH_T_REGEX;
|
||||
host_regexp->is_case_sensitive = FALSE;
|
||||
|
||||
@ -256,7 +256,7 @@ sftpfs_fill_config_entity_from_config (FILE * ssh_config_handler,
|
||||
{
|
||||
mc_search_t *pattern_regexp;
|
||||
|
||||
pattern_regexp = mc_search_new (host_pattern, -1, DEFAULT_CHARSET);
|
||||
pattern_regexp = mc_search_new (host_pattern, DEFAULT_CHARSET);
|
||||
pattern_regexp->search_type = MC_SEARCH_T_GLOB;
|
||||
pattern_regexp->is_case_sensitive = FALSE;
|
||||
pattern_regexp->is_entire_line = TRUE;
|
||||
@ -404,7 +404,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, DEFAULT_CHARSET);
|
||||
mc_search_new (config_variables[i].pattern, 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];
|
||||
|
@ -147,9 +147,9 @@ mcview_continue_search_cmd (WView * view)
|
||||
g_list_free_full (history, g_free);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
view->search = mc_search_new (view->last_search_string, -1, cp_source);
|
||||
view->search = mc_search_new (view->last_search_string, cp_source);
|
||||
#else
|
||||
view->search = mc_search_new (view->last_search_string, -1, NULL);
|
||||
view->search = mc_search_new (view->last_search_string, NULL);
|
||||
#endif
|
||||
view->search_nroff_seq = mcview_nroff_seq_new (view);
|
||||
|
||||
|
@ -142,9 +142,9 @@ mcview_dialog_search (WView * view)
|
||||
mc_search_free (view->search);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
view->search = mc_search_new (view->last_search_string, -1, cp_source);
|
||||
view->search = mc_search_new (view->last_search_string, cp_source);
|
||||
#else
|
||||
view->search = mc_search_new (view->last_search_string, -1, NULL);
|
||||
view->search = mc_search_new (view->last_search_string, NULL);
|
||||
#endif
|
||||
view->search_nroff_seq = mcview_nroff_seq_new (view);
|
||||
if (view->search != NULL)
|
||||
|
@ -71,7 +71,7 @@ START_PARAMETRIZED_TEST (test_glob_prepare_replace_str, test_glob_prepare_replac
|
||||
mc_search_t *s;
|
||||
char *dest_str;
|
||||
|
||||
s = mc_search_new (data->glob_str, -1, NULL);
|
||||
s = mc_search_new (data->glob_str, NULL);
|
||||
s->is_case_sensitive = TRUE;
|
||||
s->search_type = MC_SEARCH_T_GLOB;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user