Revert "termpty: better handle ';' in escape sequences. Closes T7475"

This reverts commit 3f432544df.
This commit is contained in:
Boris Faure 2018-11-20 10:34:37 +01:00
parent 3f432544df
commit 8fb44906cc
1 changed files with 290 additions and 297 deletions

View File

@ -104,11 +104,9 @@ _csi_arg_get(Eina_Unicode **ptr)
*ptr = b;
return -1;
}
if (*b == '\0')
{
*ptr = NULL;
return -1;
}
if (!*b)
goto error;
while ((*b >= '0') && (*b <= '9'))
{
@ -121,21 +119,15 @@ _csi_arg_get(Eina_Unicode **ptr)
if (*b == ';')
{
if (b[1])
b++;
*ptr = b;
}
else if (*b == '\0')
{
*ptr = NULL;
}
else
*ptr = b;
return sum;
error:
*ptr = NULL;
return -2;
return -1;
}
static void
@ -653,10 +645,10 @@ _handle_esc_csi_truecolor_cmyk(Termpty *ty, Eina_Unicode **ptr)
}
static void
_handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
const Eina_Unicode * const end)
_handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
{
Eina_Unicode *b = *ptr;
int first = 1;
if (b && (*b == '>'))
{ // key resources used by xterm
@ -664,14 +656,16 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
return;
}
DBG("color set");
while (b && b <= end)
while (b)
{
int arg = _csi_arg_get(&b);
DBG("arg=%d b:%p", arg, b);
if ((first) && (!b))
termpty_reset_att(&(ty->termstate.att));
else if (b)
{
first = 0;
switch (arg)
{
case -1:
EINA_FALLTHROUGH;
case 0: // reset to normal
termpty_reset_att(&(ty->termstate.att));
break;
@ -953,6 +947,7 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
break;
}
}
}
}
static void
@ -1260,9 +1255,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
ERR("csi parsing overflowed, skipping the whole buffer (binary data?)");
return cc - c;
}
if (cc == ce)
return 0;
*b = '\0';
if (cc == ce) return 0;
*b = 0;
be = b;
b = buf;
DBG(" CSI: '%s' args '%s'", _safechar(*cc), (char *) buf);
@ -1290,8 +1284,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
case 'A': // cursor up N (CUU)
CUU:
arg = _csi_arg_get(&b);
if (arg < 1)
arg = 1;
if (arg < 1) arg = 1;
DBG("cursor up %d", arg);
ty->termstate.wrapnext = 0;
ty->cursor_state.cy = MAX(0, ty->cursor_state.cy - arg);
@ -1632,7 +1625,7 @@ HVP:
_handle_esc_csi_reset_mode(ty, *cc, b);
break;
case 'm': // color set
_handle_esc_csi_color_set(ty, &b, be);
_handle_esc_csi_color_set(ty, &b);
break;
case 'n':
_handle_esc_csi_dsr(ty, b);