diff options
author | 2013-10-21 23:32:32 +0000 | |
---|---|---|
committer | 2013-10-21 23:32:32 +0000 | |
commit | ec2beb5357bc38d7dada1fc8a9acf496db5abdf1 (patch) | |
tree | 89c79c3f3d30ca50fbadea7ff61ac85d026f944d /usr.bin/mandoc/mdoc.c | |
parent | sync (diff) | |
download | wireguard-openbsd-ec2beb5357bc38d7dada1fc8a9acf496db5abdf1.tar.xz wireguard-openbsd-ec2beb5357bc38d7dada1fc8a9acf496db5abdf1.zip |
There are three kinds of input lines: text lines, macros taking
positional arguments (like Dt Fn Xr) and macros taking text as
arguments (like Nd Sh Em %T An). In the past, even the latter put
each word of their arguments into its own MDOC_TEXT node; instead,
concatenate arguments unless delimiters, keeps or spacing mode
prevent that. Regarding mandoc(1), this is internal refactoring,
no output change intended.
Once we will switch mandocdb(8) from DB to SQLite in the future,
this is going to be required to support search expressions crossing
word boundaries, and it will reduce both database sizes and build
times by a bit more than 5% each.
Diffstat (limited to 'usr.bin/mandoc/mdoc.c')
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index 52c2490014a..3464c0b48c2 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,7 +1,7 @@ -/* $Id: mdoc.c,v 1.94 2013/10/03 19:32:25 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.95 2013/10/21 23:32:32 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -578,6 +578,23 @@ mdoc_word_alloc(struct mdoc *mdoc, int line, int pos, const char *p) return(1); } +void +mdoc_word_append(struct mdoc *mdoc, const char *p) +{ + struct mdoc_node *n; + char *addstr, *newstr; + + n = mdoc->last; + addstr = roff_strdup(mdoc->roff, p); + if (-1 == asprintf(&newstr, "%s %s", n->string, addstr)) { + perror(NULL); + exit((int)MANDOCLEVEL_SYSERR); + } + free(addstr); + free(n->string); + n->string = newstr; + mdoc->next = MDOC_NEXT_SIBLING; +} static void mdoc_node_free(struct mdoc_node *p) |