]> git.dujemihanovic.xyz Git - u-boot.git/commit
cli: Move readline character-processing to a state machine
authorSimon Glass <sjg@chromium.org>
Fri, 6 Jan 2023 14:52:20 +0000 (08:52 -0600)
committerTom Rini <trini@konsulko.com>
Mon, 16 Jan 2023 19:14:11 +0000 (14:14 -0500)
commitb08e9d4b6632a72b91306690d552c125b071441e
tree948f27c1423537f8e46e78fc12352b51ec0a0294
parent7d850f85aad74ae907290ba6f911d362a0478e61
cli: Move readline character-processing to a state machine

The current cread_line() function is very long. It handles the escape
processing inline. The menu command does similar processing but at the
character level, so there is some duplication.

Split the character processing into a new function cli_ch_process() which
processes individual characters and returns the resulting input character,
taking account of escape sequences. It requires the caller to set up and
maintain its state.

Update cread_line() to use this new function.

The only intended functional change is that an invalid escape sequence
does not add invalid/control characters into the input buffer, but instead
discards these.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/Makefile
common/cli_getch.c [new file with mode: 0644]
common/cli_readline.c
include/cli.h