summaryrefslogtreecommitdiffstats
path: root/man.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-04-29 12:45:41 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-04-29 12:45:41 +0000
commit59d32b6b6f099db4e98d14846f92c95838026d6d (patch)
tree63c63032b5f693739f4b67978ba829797d59256c /man.c
parent68e287f8a84e78c626e8440ced37035bd5359eff (diff)
downloadmandoc-59d32b6b6f099db4e98d14846f92c95838026d6d.tar.gz
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 'man.c')
-rw-r--r--man.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/man.c b/man.c
index a5638c84..39a50431 100644
--- a/man.c
+++ b/man.c
@@ -145,26 +145,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);