(learn_key): return NULL if buffer is empty.

(learn_button): simplify tests: seq is never empty here.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2021-10-02 14:00:32 +03:00
parent 0e09fc3088
commit 31008bcc8e
2 changed files with 2 additions and 2 deletions

View File

@ -2193,7 +2193,7 @@ learn_key (void)
tty_keypad (TRUE);
tty_nodelay (FALSE);
*p = '\0';
return g_strdup (buffer);
return (buffer[0] != '\0' ? g_strdup (buffer) : NULL);
#undef LEARN_TIMEOUT
}

View File

@ -105,7 +105,7 @@ learn_button (WButton * button, int action)
*/
gboolean seq_ok = FALSE;
if (*seq != '\0' && strcmp (seq, "\\e") != 0 && strcmp (seq, "\\e\\e") != 0
if (strcmp (seq, "\\e") != 0 && strcmp (seq, "\\e\\e") != 0
&& strcmp (seq, "^m") != 0 && strcmp (seq, "^i") != 0
&& (seq[1] != '\0' || *seq < ' ' || *seq > '~'))
{