aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term_ascii.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-02-16 14:11:41 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-02-16 14:11:41 +0000
commitcc64f006bae2e1c1378f5d14063a116e6ef4aaaf (patch)
tree69ce8ac6b79a82f4c9fe370020853667d684e61d /term_ascii.c
parent4082a2a86f5c0ab3d58aad7ac968c049407695ca (diff)
downloadmandoc-cc64f006bae2e1c1378f5d14063a116e6ef4aaaf.tar.gz
mandoc-cc64f006bae2e1c1378f5d14063a116e6ef4aaaf.tar.zst
mandoc-cc64f006bae2e1c1378f5d14063a116e6ef4aaaf.zip
Clamp width and indent settings to sensible values.
Ignore errors for now. Patch from tedu@.
Diffstat (limited to 'term_ascii.c')
-rw-r--r--term_ascii.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/term_ascii.c b/term_ascii.c
index df191103..4ce4b686 100644
--- a/term_ascii.c
+++ b/term_ascii.c
@@ -1,4 +1,4 @@
-/* $Id: term_ascii.c,v 1.42 2014/12/31 16:52:40 schwarze Exp $ */
+/* $Id: term_ascii.c,v 1.43 2015/02/16 14:11:41 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -63,6 +63,8 @@ ascii_init(enum termenc enc, const struct mchars *mchars, char *outopts)
const char *toks[5];
char *v;
struct termp *p;
+ const char *errstr;
+ int num;
p = mandoc_calloc(1, sizeof(struct termp));
@@ -109,10 +111,14 @@ ascii_init(enum termenc enc, const struct mchars *mchars, char *outopts)
while (outopts && *outopts)
switch (getsubopt(&outopts, UNCONST(toks), &v)) {
case 0:
- p->defindent = (size_t)atoi(v);
+ num = strtonum(v, 0, 1000, &errstr);
+ if (!errstr)
+ p->defindent = num;
break;
case 1:
- p->defrmargin = (size_t)atoi(v);
+ num = strtonum(v, 0, 1000, &errstr);
+ if (!errstr)
+ p->defrmargin = num;
break;
case 2:
/*