diff --git a/lib/widget/input.c b/lib/widget/input.c index 7b6b304c6..d13b93c02 100644 --- a/lib/widget/input.c +++ b/lib/widget/input.c @@ -1219,6 +1219,14 @@ input_assign_text (WInput * in, const char *text) /* --------------------------------------------------------------------------------------------- */ +gboolean +input_is_empty (const WInput * in) +{ + return (in == NULL || in->buffer == NULL || in->buffer[0] == '\0'); +} + +/* --------------------------------------------------------------------------------------------- */ + /* Inserts text in input line */ void input_insert (WInput * in, const char *text, gboolean insert_extra_space) diff --git a/lib/widget/input.h b/lib/widget/input.h index a7c01a3e3..bba310f9b 100644 --- a/lib/widget/input.h +++ b/lib/widget/input.h @@ -92,6 +92,7 @@ void input_set_default_colors (void); cb_ret_t input_handle_char (WInput * in, int key); int input_key_is_in_map (WInput * in, int key); void input_assign_text (WInput * in, const char *text); +gboolean input_is_empty (const WInput * in); void input_insert (WInput * in, const char *text, gboolean insert_extra_space); void input_set_point (WInput * in, int pos); void input_update (WInput * in, gboolean clear_first); diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c index 4043c2d55..188458985 100644 --- a/src/filemanager/cmd.c +++ b/src/filemanager/cmd.c @@ -672,7 +672,7 @@ view_filtered_cmd (void) char *command; const char *initial_command; - if (cmdline->buffer[0] == '\0') + if (input_is_empty (cmdline)) initial_command = selection (current_panel)->fname; else initial_command = cmdline->buffer; diff --git a/src/filemanager/find.c b/src/filemanager/find.c index e92994ee6..f7d55d39e 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -802,7 +802,7 @@ find_parameters (char **start_dir, ssize_t * start_dir_len, *pattern = g_strdup (in_name->buffer); else *pattern = g_strdup (options.file_pattern ? "*" : ".*"); - *start_dir = in_start->buffer[0] != '\0' ? in_start->buffer : (char *) "."; + *start_dir = !input_is_empty (in_start) ? in_start->buffer : (char *) "."; if (in_start_dir != INPUT_LAST_TEXT) g_free (in_start_dir); in_start_dir = g_strdup (*start_dir); diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c index 3f4827487..592d542cd 100644 --- a/src/filemanager/panelize.c +++ b/src/filemanager/panelize.c @@ -256,7 +256,7 @@ add2panelize (char *label, char *command) static void add2panelize_cmd (void) { - if (pname->buffer != NULL && *pname->buffer != '\0') + if (!input_is_empty (pname)) { char *label; @@ -501,8 +501,6 @@ cd_panelize_cmd (void) void external_panelize (void) { - char *target = NULL; - if (!vfs_current_is_local ()) { message (D_ERROR, MSG_ERROR, _("Cannot run external panelize in a non-local directory")); @@ -533,11 +531,11 @@ external_panelize (void) } case B_ENTER: - target = pname->buffer; - if (target != NULL && *target) + if (!input_is_empty (pname)) { - char *cmd = g_strdup (target); + char *cmd; + cmd = g_strdup (pname->buffer); dlg_destroy (panelize_dlg); do_external_panelize (cmd); g_free (cmd);