terminal: add parser state-machine

System Internals / systemd - David Herrmann [gmail.com] - 18 July 2014 05:53 UTC

The term-parser is used to parse any input from TTY-clients. It reads CSI, DCS, OSC and ST control sequences and normal escape sequences. It doesn't do anything with the parsed data besides detecting the sequence and returning it. The caller has to react to them.

The parser also comes with its own UTF-8 helpers. The reason for that is that we don't want to assert() or hard-fail on parsing errors. Instead, we treat any invalid UTF-8 sequences as ISO-8859-1. This allows pasting invalid data into a terminal (which cannot be controlled through the TTY, anyway) and we still deal with it in a proper manner. This is _required_ for 8-bit and 7-bit DEC modes (including the g0-g3 mappings), so it's not just an ugly fallback because we can (it's still horribly ugly but at least we have an excuse).

1c9633d terminal: add parser state-machine
.gitignore | 1 +
Makefile.am | 13 +-
src/libsystemd-terminal/term-charset.c | 491 +++++++++
src/libsystemd-terminal/term-internal.h | 349 ++++++
src/libsystemd-terminal/term-parser.c | 1626 ++++++++++++++++++++++++++++
src/libsystemd-terminal/test-term-parser.c | 143 +++
6 files changed, 2622 insertions(+), 1 deletion(-)

Upstream: github.com


  • Share