summaryrefslogtreecommitdiffstats
path: root/term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-02-26 16:08:11 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-02-26 16:08:11 +0000
commit7253f34bf22e21589e886f61f77fbe93b63852a4 (patch)
tree51c21b20e119256ec3ce0bc056c2927c67b5c13d /term.c
parent69eda203817e9dc1f6bf992ff8af90702f812b24 (diff)
downloadmandoc-7253f34bf22e21589e886f61f77fbe93b63852a4.tar.gz
Support for macro widths (/usr/share/tmac/mdoc/doc-common).
Diffstat (limited to 'term.c')
-rw-r--r--term.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/term.c b/term.c
index e00ae9db..a646666e 100644
--- a/term.c
+++ b/term.c
@@ -17,6 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <assert.h>
+#include <ctype.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
@@ -276,9 +277,29 @@ const struct termact *termacts = __termacts;
static size_t
arg_width(const struct mdoc_arg *arg)
{
+ size_t len, i, v;
/* TODO */
assert(*arg->value);
+ if (0 == strcmp(*arg->value, "indent"))
+ return(INDENT);
+ if (0 == strcmp(*arg->value, "indent-two"))
+ return(INDENT * 2);
+
+ len = strlen(*arg->value);
+ assert(len > 0);
+
+ for (i = 0; i < len - 1; i++)
+ if ( ! isdigit((int)(*arg->value)[i]))
+ break;
+
+ if (i == len - 1) {
+ if ('n' == (*arg->value)[len - 1]) {
+ v = (size_t)atoi(*arg->value);
+ return(v);
+ }
+
+ }
return(strlen(*arg->value));
}
@@ -293,7 +314,6 @@ arg_offset(const struct mdoc_arg *arg)
return(INDENT);
if (0 == strcmp(*arg->value, "indent-two"))
return(INDENT * 2);
-
return(strlen(*arg->value));
}