aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/xstd.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-01-17 16:15:27 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-01-17 16:15:27 +0000
commita2320c4fc025a6262bc6cfa6e420d85fe8d60bd6 (patch)
treeb2c089949ddd571f223c3377bcf2f559195f2d88 /xstd.c
parent3ef2ed38138f74f57e8bac7be877cd7f644c6fa5 (diff)
downloadmandoc-a2320c4fc025a6262bc6cfa6e420d85fe8d60bd6.tar.gz
mandoc-a2320c4fc025a6262bc6cfa6e420d85fe8d60bd6.tar.zst
mandoc-a2320c4fc025a6262bc6cfa6e420d85fe8d60bd6.zip
Documentation, more validations, cleaned up actions, added Nm action.
Diffstat (limited to 'xstd.c')
-rw-r--r--xstd.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/xstd.c b/xstd.c
index c236e2df..eb36b404 100644
--- a/xstd.c
+++ b/xstd.c
@@ -1,4 +1,4 @@
-/* $Id: xstd.c,v 1.2 2008/12/29 18:08:44 kristaps Exp $ */
+/* $Id: xstd.c,v 1.3 2009/01/17 16:15:27 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -16,6 +16,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+#include <assert.h>
#include <err.h>
#include <stdlib.h>
#include <string.h>
@@ -75,6 +76,30 @@ xstrdup(const char *p)
}
+int
+xstrlcats(char *buf, const struct mdoc_node *n, size_t sz)
+{
+ char *p;
+
+ assert(sz > 0);
+ assert(buf);
+ *buf = 0;
+
+ for ( ; n; n = n->next) {
+ assert(MDOC_TEXT == n->type);
+ p = n->data.text.string;
+ if ( ! xstrlcat(buf, p, sz))
+ return(0);
+ if (n->next && ! xstrlcat(buf, " ", sz))
+ return(0);
+ }
+
+ return(1);
+}
+
+
+
+
#ifdef __linux__
/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */