aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-10-21 23:47:58 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-10-21 23:47:58 +0000
commit6f0fdff7bd838e5309174d1f70528d04e7474a18 (patch)
tree2a08b6583b1b1f3c153b9a539419c9a3d39d0301 /mdoc.c
parentee091385eb708ecd7a3b7c555c2d4172dfdbfa59 (diff)
downloadmandoc-6f0fdff7bd838e5309174d1f70528d04e7474a18.tar.gz
mandoc-6f0fdff7bd838e5309174d1f70528d04e7474a18.tar.zst
mandoc-6f0fdff7bd838e5309174d1f70528d04e7474a18.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. Regarding mandocdb(8), this fixes yet another regression introduced when switching from DB to SQLite: The ability to search for strings crossing word boundaries was lost and is hereby restored. At the same time, database sizes and build times are both reduced by a bit more than 5% each.
Diffstat (limited to 'mdoc.c')
-rw-r--r--mdoc.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/mdoc.c b/mdoc.c
index c5cfef3c..228728fc 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,7 +1,7 @@
-/* $Id: mdoc.c,v 1.204 2013/10/05 22:08:12 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.205 2013/10/21 23:47:58 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
@@ -582,6 +582,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)