[vte] parser: Store the string terminator for DCS sequences
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] parser: Store the string terminator for DCS sequences
- Date: Sun, 18 Oct 2020 22:17:08 +0000 (UTC)
commit e19b69998492465fb555753b52ebce0a0e46d0ed
Author: Christian Persch <chpe src gnome org>
Date: Mon Oct 19 00:16:36 2020 +0200
parser: Store the string terminator for DCS sequences
This will be used in a subsequent commit.
src/parser-cat.cc | 2 +-
src/parser-glue.hh | 10 ++++++++++
src/parser-test.cc | 10 +++++-----
src/parser.cc | 6 ++++--
src/parser.hh | 1 +
src/vte.cc | 2 +-
src/vteseq.cc | 2 +-
7 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/src/parser-cat.cc b/src/parser-cat.cc
index 4dfb472a..15e9fb9a 100644
--- a/src/parser-cat.cc
+++ b/src/parser-cat.cc
@@ -585,7 +585,7 @@ public:
auto cmd = seq.command();
switch (cmd) {
case VTE_CMD_OSC:
- if (seq.terminator() == 7 /* BEL */)
+ if (seq.st() == 7 /* BEL */)
warn("OSC terminated by BEL may be ignored; use ST (ESC \\) instead.");
break;
diff --git a/src/parser-glue.hh b/src/parser-glue.hh
index 90c41379..0b1ba213 100644
--- a/src/parser-glue.hh
+++ b/src/parser-glue.hh
@@ -150,6 +150,16 @@ public:
return m_seq->terminator;
}
+ /* st:
+ *
+ * This is the string terminator ending a OSC, DCS, APC, PM, or SOS sequence
+ *
+ * Returns: the string terminator character
+ */
+ inline constexpr uint32_t st() const noexcept
+ {
+ return m_seq->st;
+ }
/* is_c1:
*
diff --git a/src/parser-test.cc b/src/parser-test.cc
index b0a70bba..f7b32993 100644
--- a/src/parser-test.cc
+++ b/src/parser-test.cc
@@ -1248,19 +1248,19 @@ feed_parser_st(vte_seq_builder& b,
switch (st) {
case u32SequenceBuilder::ST::NONE:
- g_assert_cmpuint(seq.terminator(), ==, 0);
+ g_assert_cmpuint(seq.st(), ==, 0);
break;
case u32SequenceBuilder::ST::DEFAULT:
- g_assert_cmpuint(seq.terminator(), ==, c1 ? 0x9c /* ST */ : 0x5c /* BACKSLASH */);
+ g_assert_cmpuint(seq.st(), ==, c1 ? 0x9c /* ST */ : 0x5c /* BACKSLASH */);
break;
case u32SequenceBuilder::ST::C0:
- g_assert_cmpuint(seq.terminator(), ==, 0x5c /* BACKSLASH */);
+ g_assert_cmpuint(seq.st(), ==, 0x5c /* BACKSLASH */);
break;
case u32SequenceBuilder::ST::C1:
- g_assert_cmpuint(seq.terminator(), ==, 0x9c /* ST */);
+ g_assert_cmpuint(seq.st(), ==, 0x9c /* ST */);
break;
case u32SequenceBuilder::ST::BEL:
- g_assert_cmpuint(seq.terminator(), ==, 0x7 /* BEL */);
+ g_assert_cmpuint(seq.st(), ==, 0x7 /* BEL */);
break;
}
diff --git a/src/parser.cc b/src/parser.cc
index ca2eb56b..b9e1d20a 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -881,6 +881,7 @@ parser_dcs_consume(vte_parser_t* parser,
parser->seq.type = VTE_SEQ_DCS;
parser->seq.terminator = raw;
+ parser->seq.st = 0;
parser->seq.command = vte_parse_host_dcs(&parser->seq);
return VTE_SEQ_NONE;
@@ -950,7 +951,7 @@ parser_osc(vte_parser_t* parser,
parser->seq.type = VTE_SEQ_OSC;
parser->seq.command = VTE_CMD_OSC;
- parser->seq.terminator = raw;
+ parser->seq.st = raw;
return parser->seq.type;
}
@@ -959,7 +960,8 @@ static int
parser_dcs(vte_parser_t* parser,
uint32_t raw)
{
- /* parser->seq was already filled in parser_dcs_consume() */
+ /* Most of parser->seq was already filled in parser_dcs_consume() */
+ parser->seq.st = raw;
vte_seq_string_finish(&parser->seq.arg_str);
diff --git a/src/parser.hh b/src/parser.hh
index 2d9f1f0f..5798d164 100644
--- a/src/parser.hh
+++ b/src/parser.hh
@@ -195,6 +195,7 @@ struct vte_seq_t {
vte_seq_arg_t args[VTE_PARSER_ARG_MAX];
vte_seq_string_t arg_str;
uint32_t introducer;
+ uint32_t st;
};
struct vte_parser_t {
diff --git a/src/vte.cc b/src/vte.cc
index d3d8c83b..981b1bfd 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -4155,7 +4155,7 @@ Terminal::send(vte::parser::Sequence const& seq,
*/
send(builder, false,
vte::parser::u8SequenceBuilder::Introducer::DEFAULT,
- seq.terminator() == 0x7 ? vte::parser::u8SequenceBuilder::ST::BEL
+ seq.st() == 0x7 ? vte::parser::u8SequenceBuilder::ST::BEL
: vte::parser::u8SequenceBuilder::ST::DEFAULT);
} else {
send(builder, false);
diff --git a/src/vteseq.cc b/src/vteseq.cc
index ce9b9313..4f2d6b83 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -88,7 +88,7 @@ vte::parser::Sequence::print() const noexcept
}
g_printerr(" ]");
}
- if (m_seq->type == VTE_SEQ_OSC) {
+ if (m_seq->type == VTE_SEQ_OSC || m_seq->type == VTE_SEQ_DCS) {
char* str = string_param();
g_printerr(" \"%s\"", str);
g_free(str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]