aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit45a0a327d5183355d3878057425e8aa9935d70db (patch)
tree448aed7c4693391cdd674fdd7257a4435fdc216e /man.c
parent882c99984a5b562bef7d6cb4685a04fba62a7852 (diff)
downloadmandoc-45a0a327d5183355d3878057425e8aa9935d70db.tar.gz
mandoc-45a0a327d5183355d3878057425e8aa9935d70db.tar.zst
mandoc-45a0a327d5183355d3878057425e8aa9935d70db.zip
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.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/man.c b/man.c
index 9976304e..9c26e4e7 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.169 2017/04/24 23:06:18 schwarze Exp $ */
+/* $Id: man.c,v 1.170 2017/04/29 12:45:41 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);