Clarify checks of input line content returned from quick dialog.

If quick dialog is finished with value other than B_CANCEL,
string value of input line isn't NULL.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2022-08-04 11:03:32 +03:00
parent 79645187c6
commit 36abab7186
7 changed files with 22 additions and 11 deletions

View File

@ -113,7 +113,7 @@ mcdiffview_dialog_search (WDiff * dview)
g_strfreev (list_of_types); g_strfreev (list_of_types);
if ((qd_result == B_CANCEL) || (exp == NULL) || (exp[0] == '\0')) if (qd_result == B_CANCEL || exp[0] == '\0')
{ {
g_free (exp); g_free (exp);
return FALSE; return FALSE;

View File

@ -200,7 +200,7 @@ edit_options_dialog (WDialog * h)
if (!option_cursor_beyond_eol) if (!option_cursor_beyond_eol)
g_list_foreach (GROUP (h)->widgets, edit_reset_over_col, NULL); g_list_foreach (GROUP (h)->widgets, edit_reset_over_col, NULL);
if (p != NULL) if (*p != '\0')
{ {
option_word_wrap_line_length = atoi (p); option_word_wrap_line_length = atoi (p);
if (option_word_wrap_line_length <= 0) if (option_word_wrap_line_length <= 0)
@ -208,7 +208,7 @@ edit_options_dialog (WDialog * h)
g_free (p); g_free (p);
} }
if (q != NULL) if (*q != '\0')
{ {
option_tab_spacing = atoi (q); option_tab_spacing = atoi (q);
if (option_tab_spacing <= 0) if (option_tab_spacing <= 0)

View File

@ -119,7 +119,7 @@ edit_dialog_search_show (WEdit * edit)
g_strfreev (list_of_types); g_strfreev (list_of_types);
if ((dialog_result == B_CANCEL) || (search_text == NULL) || (search_text[0] == '\0')) if (dialog_result == B_CANCEL || search_text[0] == '\0')
{ {
g_free (search_text); g_free (search_text);
return FALSE; return FALSE;

View File

@ -612,7 +612,12 @@ configure_box (void)
#endif #endif
if (quick_dialog (&qdlg) == B_ENTER) if (quick_dialog (&qdlg) == B_ENTER)
old_esc_mode_timeout = atoi (time_out_new); {
if (time_out_new[0] == '\0')
old_esc_mode_timeout = 0;
else
old_esc_mode_timeout = atoi (time_out_new);
}
g_free (time_out_new); g_free (time_out_new);
} }
@ -1177,7 +1182,10 @@ configure_vfs_box (void)
if (quick_dialog (&qdlg) != B_CANCEL) if (quick_dialog (&qdlg) != B_CANCEL)
{ {
/* cppcheck-suppress uninitvar */ /* cppcheck-suppress uninitvar */
vfs_timeout = atoi (ret_timeout); if (ret_timeout[0] == '\0')
vfs_timeout = 0;
else
vfs_timeout = atoi (ret_timeout);
g_free (ret_timeout); g_free (ret_timeout);
if (vfs_timeout < 0 || vfs_timeout > 10000) if (vfs_timeout < 0 || vfs_timeout > 10000)
@ -1190,7 +1198,10 @@ configure_vfs_box (void)
/* cppcheck-suppress uninitvar */ /* cppcheck-suppress uninitvar */
ftpfs_proxy_host = ret_ftp_proxy; ftpfs_proxy_host = ret_ftp_proxy;
/* cppcheck-suppress uninitvar */ /* cppcheck-suppress uninitvar */
ftpfs_directory_timeout = atoi (ret_directory_timeout); if (ret_directory_timeout[0] == '\0')
ftpfs_directory_timeout = 0;
else
ftpfs_directory_timeout = atoi (ret_directory_timeout);
g_free (ret_directory_timeout); g_free (ret_directory_timeout);
#endif #endif
} }

View File

@ -1405,7 +1405,7 @@ file_mask_dialog (file_op_context_t * ctx, FileOperation operation, gboolean onl
ctx->umask_kill = i2 ^ 0777777; ctx->umask_kill = i2 ^ 0777777;
} }
if (dest_dir == NULL || *dest_dir == '\0') if (*dest_dir == '\0')
{ {
g_free (def_text_secure); g_free (def_text_secure);
g_free (source_mask); g_free (source_mask);

View File

@ -2570,7 +2570,7 @@ panel_select_unselect_files_dialog (select_flags_t * flags, const char *title,
if (quick_dialog (&qdlg) == B_CANCEL) if (quick_dialog (&qdlg) == B_CANCEL)
return NULL; return NULL;
if (reg_exp == NULL || *reg_exp == '\0') if (*reg_exp == '\0')
{ {
g_free (reg_exp); g_free (reg_exp);
if (str != NULL) if (str != NULL)

View File

@ -110,7 +110,7 @@ mcview_dialog_search (WView * view)
g_strfreev (list_of_types); g_strfreev (list_of_types);
if ((qd_result == B_CANCEL) || (exp == NULL) || (exp[0] == '\0')) if (qd_result == B_CANCEL || exp[0] == '\0')
{ {
g_free (exp); g_free (exp);
return FALSE; return FALSE;
@ -196,7 +196,7 @@ mcview_dialog_goto (WView * view, off_t * offset)
*offset = -1; *offset = -1;
/* check input line value */ /* check input line value */
res = (qd_result != B_CANCEL && exp != NULL && exp[0] != '\0'); res = (qd_result != B_CANCEL && exp[0] != '\0');
if (res) if (res)
{ {
int base = (current_goto_type == MC_VIEW_GOTO_OFFSET_HEX) ? 16 : 10; int base = (current_goto_type == MC_VIEW_GOTO_OFFSET_HEX) ? 16 : 10;