aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit45a0a327d5183355d3878057425e8aa9935d70db (patch)
tree448aed7c4693391cdd674fdd7257a4435fdc216e /mdoc.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 'mdoc.c')
-rw-r--r--mdoc.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/mdoc.c b/mdoc.c
index d3da99d9..a1e3a0f9 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.262 2017/04/24 23:06:18 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.263 2017/04/29 12:45:41 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);