diff options
author | Cem Keylan <cem@ckyln.com> | 2020-10-19 13:43:05 +0300 |
---|---|---|
committer | Cem Keylan <cem@ckyln.com> | 2020-10-19 13:43:05 +0300 |
commit | 75666cb76815ffd35a30153c6cabc53601e9e2de (patch) | |
tree | 89385348ea2708d9371704e188bcd1004d7a589a /usr.bin/mandoc/term_ascii.c | |
parent | 2171aa6ddbd6f9cbec58ac40ae0b5e511d1b871a (diff) | |
download | otools-75666cb76815ffd35a30153c6cabc53601e9e2de.tar.gz |
usr.bin: update to 6.8
Diffstat (limited to 'usr.bin/mandoc/term_ascii.c')
-rw-r--r-- | usr.bin/mandoc/term_ascii.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/usr.bin/mandoc/term_ascii.c b/usr.bin/mandoc/term_ascii.c index 9b28060..8b89deb 100644 --- a/usr.bin/mandoc/term_ascii.c +++ b/usr.bin/mandoc/term_ascii.c @@ -1,7 +1,7 @@ -/* $OpenBSD: term_ascii.c,v 1.50 2019/07/19 21:45:37 schwarze Exp $ */ +/* $OpenBSD: term_ascii.c,v 1.52 2020/09/09 13:40:24 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2014,2015,2017,2018,2020 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -222,7 +222,10 @@ ascii_endline(struct termp *p) { p->line++; - p->tcol->offset -= p->ti; + if ((int)p->tcol->offset > p->ti) + p->tcol->offset -= p->ti; + else + p->tcol->offset = 0; p->ti = 0; putchar('\n'); } @@ -232,7 +235,14 @@ ascii_advance(struct termp *p, size_t len) { size_t i; - assert(len < UINT16_MAX); + /* + * XXX We used to have "assert(len < UINT16_MAX)" here. + * that is not quite right because the input document + * can trigger that by merely providing large input. + * For now, simply truncate. + */ + if (len > 256) + len = 256; for (i = 0; i < len; i++) putchar(' '); } @@ -369,7 +379,14 @@ locale_advance(struct termp *p, size_t len) { size_t i; - assert(len < UINT16_MAX); + /* + * XXX We used to have "assert(len < UINT16_MAX)" here. + * that is not quite right because the input document + * can trigger that by merely providing large input. + * For now, simply truncate. + */ + if (len > 256) + len = 256; for (i = 0; i < len; i++) putwchar(L' '); } @@ -379,7 +396,10 @@ locale_endline(struct termp *p) { p->line++; - p->tcol->offset -= p->ti; + if ((int)p->tcol->offset > p->ti) + p->tcol->offset -= p->ti; + else + p->tcol->offset = 0; p->ti = 0; putwchar(L'\n'); } |