]> git.baikalelectronics.ru Git - uboot.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)
commitc27dce8c773153c6f33c3a842049ef9283f08dce
tree948f27c1423537f8e46e78fc12352b51ec0a0294
parent06a892504cb967dd746e818e241077cc9e5d97aa
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