Ticket #4397: sort in editor without arguments stopped working.

* (input_get_text): never return NULL. If buffer is empty, return an
empty allocated string.
  * (input_push_history): use new input_get_text.
  * (find_parameters): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2022-08-03 16:51:09 +03:00
parent 9f15305dc2
commit 318315399b
2 changed files with 6 additions and 11 deletions

View File

@ -220,14 +220,12 @@ input_push_history (WInput * in)
char *t;
gboolean empty;
/* FIXME: don't use input_get_text() to avoid extra checks */
t = g_strstrip (g_strndup (in->buffer->str, in->buffer->len));
t = g_strstrip (input_get_text (in));
empty = *t == '\0';
if (!empty)
{
g_free (t);
/* FIXME: don't use input_get_text() to avoid extra checks */
t = g_strndup (in->buffer->str, in->buffer->len);
t = input_get_text (in);
if (in->history.name != NULL && in->strip_password)
{
@ -1159,14 +1157,10 @@ input_assign_text (WInput * in, const char *text)
* @param in input line
*
* @return newly allocated string that contains a copy of @in's text.
* If @in is empty, return NULL.
*/
char *
input_get_text (const WInput * in)
{
if (input_is_empty (in))
return NULL;
return g_strndup (in->buffer->str, in->buffer->len);
}

View File

@ -823,10 +823,11 @@ find_parameters (WPanel * panel, char **start_dir, ssize_t * start_dir_len,
g_free (options.ignore_dirs);
options.ignore_dirs = input_get_text (in_ignore);
*content = input_get_text (in_with);
*pattern = input_get_text (in_name);
if (*pattern == NULL)
*content = !input_is_empty (in_with) ? input_get_text (in_with) : NULL;
if (input_is_empty (in_name))
*pattern = g_strdup (options.file_pattern ? "*" : ".*");
else
*pattern = input_get_text (in_name);
*start_dir = !input_is_empty (in_start) ? in_start->buffer->str : (char *) ".";
if (in_start_dir != INPUT_LAST_TEXT)
g_free (in_start_dir);