dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit db3486ef755954be29f2f440221f4133bc802ec0
parent 9b48010e7776b25754a80bd0a3b101c2d8485a15
Author: Marc Andre Tanner <mat@brain-dump.org>
Date:   Mon, 18 Apr 2011 12:53:17 +0200

madtty: avoid the use of asserts

They are compiled out most of the time and therefore won't protect us
from crashing.

Signed-off-by: Marc Andre Tanner <mat@brain-dump.org>

Diffstat:
madtty.c | 26+++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/madtty.c b/madtty.c @@ -21,7 +21,6 @@ */ #define _GNU_SOURCE -#include <assert.h> #include <ctype.h> #include <errno.h> #include <fcntl.h> @@ -399,9 +398,10 @@ static void interpret_csi_SGR(madtty_t *t, int param[], int pcount) t->curfg = param[i] - 30; break; case 38: - assert(param[i + 1] == 5); - t->curfg = param[i + 2]; - i += 2; + if ((i + 2) < pcount && param[i + 1] == 5) { + t->curfg = param[i + 2]; + i += 2; + } break; case 39: t->curfg = -1; @@ -410,9 +410,10 @@ static void interpret_csi_SGR(madtty_t *t, int param[], int pcount) t->curbg = param[i] - 40; break; case 48: - assert(param[i + 1] == 5); - t->curbg = param[i + 2]; - i += 2; + if ((i + 2) < pcount && param[i + 1] == 5) { + t->curbg = param[i + 2]; + i += 2; + } break; case 49: t->curbg = -1; @@ -980,10 +981,13 @@ static void madtty_putc(madtty_t *t, wchar_t wc) } if (t->escaped) { - assert (t->elen + 1 < (int)sizeof(t->ebuf)); - t->ebuf[t->elen] = wc; - t->ebuf[++t->elen] = '\0'; - try_interpret_escape_seq(t); + if (t->elen + 1 < (int)sizeof(t->ebuf)) { + t->ebuf[t->elen] = wc; + t->ebuf[++t->elen] = '\0'; + try_interpret_escape_seq(t); + } else { + cancel_escape_sequence(t); + } } else if (IS_CONTROL(wc)) { madtty_process_nonprinting(t, wc); } else {