summaryrefslogtreecommitdiffstats
path: root/mdoc.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 /mdoc.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 'mdoc.c')
-rw-r--r--mdoc.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/mdoc.c b/mdoc.c
index f370ec9d..64404025 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -302,25 +302,18 @@ mdoc_pmacro(struct roff_man *mdoc, int ln, char *buf, int offs)
{
struct roff_node *n;
const char *cp;
+ size_t sz;
enum roff_tok tok;
- int i, sv;
- char mac[5];
+ int sv;
- sv = 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 > 1 && i < 4) ? mdoc_hash_find(mac) : TOKEN_NONE;
+ /* Determine the line macro. */
+ sv = offs;
+ tok = TOKEN_NONE;
+ for (sz = 0; sz < 4 && strchr(" \t\\", buf[offs]) == NULL; sz++)
+ offs++;
+ if (sz == 2 || sz == 3)
+ tok = roffhash_find(mdoc->mdocmac, buf + sv, sz);
if (tok == TOKEN_NONE) {
mandoc_msg(MANDOCERR_MACRO, mdoc->parse,
ln, sv, buf + sv - 1);