aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-30 19:42:46 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-30 19:42:46 +0000
commit8acc3b891dabf5ba96b71771c77061769c3e29b8 (patch)
treefc302648c3e7f3d10a9faa50bef0049b9426e0c9
parentrender: don't pass a struct buffer when all we need is a cairo_t (diff)
vt: remove almost all abort() calls
Replace with generic error log messages that simply says the ESC/CSI/OSC sequence is unhandled. This can mean either invalid or unimplemented, depending on the context.
-rw-r--r--csi.c97
-rw-r--r--osc.c20
-rw-r--r--vt.c15
3 files changed, 49 insertions, 83 deletions
diff --git a/csi.c b/csi.c
index a82f03f3..03879cd5 100644
--- a/csi.c
+++ b/csi.c
@@ -20,6 +20,9 @@
static uint32_t colors256[256];
+#define UNHANDLED() LOG_ERR("unhandled: %s", csi_as_string(term, final))
+#define UNHANDLED_SGR() LOG_ERR("unhandled: %s", csi_as_string(term, 'm'))
+
static void __attribute__((constructor))
initialize_colors256(void)
{
@@ -169,16 +172,13 @@ csi_sgr(struct terminal *term)
/* 7 - color space associated with tolerance */
term->vt.attrs.foreground = 1 << 30 | r << 16 | g << 8 | b;
- } else {
- LOG_ERR("invalid CSI SGR sequence");
- abort();
- }
+ } else
+ UNHANDLED_SGR();
}
- else {
- LOG_ERR("invalid CSI SGR sequence");
- abort();
- }
+ else
+ UNHANDLED_SGR();
+
break;
}
@@ -239,17 +239,13 @@ csi_sgr(struct terminal *term)
/* 7 - color space associated with tolerance */
term->vt.attrs.background = 1 << 30 | r << 16 | g << 8 | b;
- } else {
- LOG_ERR("invalid CSI SGR sequence");
- abort();
- }
+ } else
+ UNHANDLED_SGR();
}
- else {
- LOG_ERR("invalid CSI SGR sequence");
- abort();
- break;
- }
+ else
+ UNHANDLED_SGR();
+
break;
}
case 49:
@@ -281,8 +277,7 @@ csi_sgr(struct terminal *term)
break;
default:
- LOG_ERR("unimplemented: CSI: SGR: %u", term->vt.params.v[i].value);
- abort();
+ UNHANDLED_SGR();
break;
}
}
@@ -392,9 +387,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
}
default:
- LOG_ERR("%s: invalid argument: %d",
- csi_as_string(term, final), param);
- abort();
+ UNHANDLED();
break;
}
break;
@@ -428,9 +421,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
default:
- LOG_ERR("%s: invalid argument: %d",
- csi_as_string(term, final), param);
- abort();
+ UNHANDLED();
break;
}
@@ -644,21 +635,17 @@ csi_dispatch(struct terminal *term, uint8_t final)
}
default:
- LOG_ERR("unimplemented: %s, parameter = %d",
- csi_as_string(term, final), param);
- abort();
+ UNHANDLED();
break;
}
- } else {
- LOG_ERR("%s: missing parameter", csi_as_string(term, final));
- abort();
- }
+ } else
+ UNHANDLED();
+
break;
}
default:
- LOG_ERR("unimplemented: %s", csi_as_string(term, final));
- abort();
+ UNHANDLED();
break;
}
@@ -747,10 +734,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
default:
- LOG_ERR("%s: unimplemented param: %d",
- csi_as_string(term, final),
- term->vt.params.v[i].value);
- abort();
+ UNHANDLED();
break;
}
}
@@ -831,10 +815,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
default:
- LOG_ERR("%s: unimplemented param: %d",
- csi_as_string(term, final),
- term->vt.params.v[i].value);
- abort();
+ UNHANDLED();
break;
}
}
@@ -843,8 +824,8 @@ csi_dispatch(struct terminal *term, uint8_t final)
case 'p': {
if (term->vt.private[1] != '$') {
- LOG_ERR("unimplemented: %s", csi_as_string(term, final));
- abort();
+ UNHANDLED();
+ break;
}
unsigned param = vt_param_get(term, 0, 0);
@@ -874,8 +855,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
default:
- LOG_ERR("unimplemented: %s", csi_as_string(term, final));
- abort();
+ UNHANDLED();
break;
}
}
@@ -891,15 +871,15 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
default:
- LOG_ERR("unimplemented: CSI %s", csi_as_string(term, final));
- abort();
+ UNHANDLED();
+ break;
}
}
break;
default:
- LOG_ERR("unimplemented: %s", csi_as_string(term, final));
- abort();
+ UNHANDLED();
+ break;
}
break; /* private == '?' */
@@ -910,10 +890,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
case 'c': {
int param = vt_param_get(term, 0, 0);
if (param != 0) {
- LOG_ERR(
- "unimplemented: send device attributes with param = %d",
- param);
- abort();
+ UNHANDLED();
break;
}
@@ -945,8 +922,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
break; /* final == 'm' */
default:
- LOG_ERR("unimplemented: %s", csi_as_string(term, final));
- abort();
+ UNHANDLED();
break;
}
@@ -984,8 +960,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
}
default:
- LOG_ERR("unimplemented: %s", csi_as_string(term, final));
- abort();
+ UNHANDLED();
break;
}
break; /* private == ' ' */
@@ -998,16 +973,14 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
default:
- LOG_ERR("unimplemented: %s", csi_as_string(term, final));
- abort();
+ UNHANDLED();
break;
}
break; /* private == '!' */
}
default:
- LOG_ERR("unimplemented: %s", csi_as_string(term, final));
- abort();
+ UNHANDLED();
break;
}
}
diff --git a/osc.c b/osc.c
index f3954031..20d80c9e 100644
--- a/osc.c
+++ b/osc.c
@@ -14,6 +14,8 @@
#include "terminal.h"
#include "vt.h"
+#define UNHANDLED() LOG_ERR("unhandled: OSC: %.*s", (int)term->vt.osc.idx, term->vt.osc.data)
+
static void
osc_query(struct terminal *term, unsigned param)
{
@@ -39,9 +41,7 @@ osc_query(struct terminal *term, unsigned param)
}
default:
- LOG_ERR("unimplemented: OSC query: %.*s",
- (int)term->vt.osc.idx, term->vt.osc.data);
- abort();
+ UNHANDLED();
break;
}
}
@@ -55,8 +55,6 @@ osc_to_clipboard(struct terminal *term, const char *target,
if (decoded == NULL) {
LOG_WARN("OSC: invalid clipboard data: %s", base64_data);
- /* TODO: clear selection */
- abort();
return;
}
@@ -235,14 +233,14 @@ osc_dispatch(struct terminal *term)
}
if (!isdigit(c)) {
- LOG_ERR("OSC: invalid parameter: %.*s",
- (int)term->vt.osc.idx, term->vt.osc.data);
- abort();
+ UNHANDLED();
+ return;
}
param *= 10;
param += c - '0';
}
+
LOG_DBG("OCS: %.*s (param = %d)",
(int)term->vt.osc.idx, term->vt.osc.data, param);
@@ -260,7 +258,7 @@ osc_dispatch(struct terminal *term)
case 30: /* Set tab title */
break;
-
+
case 52: /* Copy to/from clipboard/primary */
osc_selection(term, string);
break;
@@ -275,9 +273,7 @@ osc_dispatch(struct terminal *term)
break;
default:
- LOG_ERR("unimplemented: OSC: %.*s",
- (int)term->vt.osc.idx, term->vt.osc.data);
- abort();
+ UNHANDLED();
break;
}
}
diff --git a/vt.c b/vt.c
index 0867d54f..cfb31884 100644
--- a/vt.c
+++ b/vt.c
@@ -12,6 +12,8 @@
#include "grid.h"
#include "osc.h"
+#define UNHANDLED() LOG_ERR("unhandled: %s", esc_as_string(term, final))
+
/* https://vt100.net/emu/dec_ansi_parser */
enum state {
@@ -613,8 +615,7 @@ esc_dispatch(struct terminal *term, uint8_t final)
case '+': term->charset[3] = CHARSET_ASCII; break;
default:
- LOG_ERR("%s: invalid charset identifier", esc_as_string(term, final));
- abort();
+ UNHANDLED();
break;
}
break;
@@ -658,8 +659,7 @@ esc_dispatch(struct terminal *term, uint8_t final)
case '+': term->charset[3] = CHARSET_GRAPHIC; break;
default:
- LOG_ERR("%s: invalid charset identifier", esc_as_string(term, final));
- abort();
+ UNHANDLED();
break;
}
break;
@@ -674,8 +674,7 @@ esc_dispatch(struct terminal *term, uint8_t final)
break;
default:
- LOG_ERR("unimplemented: ESC: %s", esc_as_string(term, final));
- abort();
+ UNHANDLED();
break;
}
}
@@ -888,10 +887,8 @@ action(struct terminal *term, enum action _action, uint8_t c)
term->vt.private[0] = c;
else if (term->vt.private[1] == 0)
term->vt.private[1] = c;
- else {
+ else
LOG_ERR("only two private/intermediate characters supported");
- abort();
- }
break;
case ACTION_ESC_DISPATCH: