summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/man.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-04-29 12:43:56 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-04-29 12:43:56 +0000
commite4a03762c83065142a21c681f115e3405fd81a31 (patch)
tree12ddc0987a0fb73157710f647ae20b6981ab0fc6 /usr.bin/mandoc/man.c
parent11ddd3024c30f04c99558f38519a4e5ff9b09661 (diff)
Parser unification: use nice ohashes for all three request and macro tables;
no functional change, minus two source files, minus 200 lines of code.
Diffstat (limited to 'usr.bin/mandoc/man.c')
-rw-r--r--usr.bin/mandoc/man.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 8246784d40e..1db9e879202 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man.c,v 1.117 2017/04/24 23:06:09 schwarze Exp $ */
+/* $OpenBSD: man.c,v 1.118 2017/04/29 12:43:55 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -143,26 +143,19 @@ man_pmacro(struct roff_man *man, int ln, char *buf, int offs)
{
struct roff_node *n;
const char *cp;
- int tok;
- int i, ppos;
+ size_t sz;
+ enum roff_tok tok;
+ int ppos;
int bline;
- char mac[5];
- ppos = offs;
-
- /*
- * Copy the first word into a nil-terminated buffer.
- * Stop when a space, tab, escape, or eoln is encountered.
- */
-
- i = 0;
- while (i < 4 && strchr(" \t\\", buf[offs]) == NULL)
- mac[i++] = buf[offs++];
-
- mac[i] = '\0';
-
- tok = (i > 0 && i < 4) ? man_hash_find(mac) : TOKEN_NONE;
+ /* Determine the line macro. */
+ ppos = offs;
+ tok = TOKEN_NONE;
+ for (sz = 0; sz < 4 && strchr(" \t\\", buf[offs]) == NULL; sz++)
+ offs++;
+ if (sz > 0 && sz < 4)
+ tok = roffhash_find(man->manmac, buf + ppos, sz);
if (tok == TOKEN_NONE) {
mandoc_msg(MANDOCERR_MACRO, man->parse,
ln, ppos, buf + ppos - 1);