vtgl

terminal emulator implemented in OpenGL
git clone anongit@rnpnr.xyz:vtgl.git
Log | Files | Refs | Feed | LICENSE

Commit: 06e5d79dbf035b94e982cfdf77c0d51a1335a5a3
Parent: dec1f3d5e9f824da6abb36545b2a3a07054cd0c7
Author: Randy Palamar
Date:   Thu, 20 Feb 2025 22:01:27 -0700

parse_osc: cleanup excess branches and gotos

Diffstat:
Mterminal.c | 21+++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/terminal.c b/terminal.c @@ -1081,7 +1081,7 @@ parse_osc(s8 *raw, OSC *osc) { BEGIN_TIMED_BLOCK(); - b32 result = 1; + b32 result = 0; /* TODO(rnp): make this whole function re-entrant */ zero_struct(osc); osc->raw.data = raw->data; @@ -1091,9 +1091,7 @@ parse_osc(s8 *raw, OSC *osc) osc->cmd = cmd.i; osc->arg = cmd.unparsed; osc->raw.len = osc->arg.data - raw->data; - *raw = consume(*raw, osc->raw.len); - } else { - result = 0; + *raw = consume(*raw, osc->raw.len); } if (osc->arg.len && peek(osc->arg, 0) == ';') { @@ -1104,21 +1102,20 @@ parse_osc(s8 *raw, OSC *osc) while (raw->len) { u32 cp = get_ascii(raw); osc->raw.len++; - if (cp == '\a') - goto end; + if (cp == '\a') { + result = 1; + break; + } if (cp == 0x1B && (raw->len && peek(*raw, 0) == '\\')) { get_ascii(raw); osc->raw.len++; - goto end; + result = 1; + break; } osc->arg.len++; } - /* NOTE: if we fell out of the loop then we ran out of characters */ - result = 0; - } else { - result = 0; } -end: + END_TIMED_BLOCK(); return result;