aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--man.c48
-rw-r--r--man.h3
-rw-r--r--mandocdb.c6
-rw-r--r--mdoc.c41
-rw-r--r--mdoc.h10
-rw-r--r--mdoc_validate.c10
-rw-r--r--roff.c48
-rw-r--r--roff.h6
8 files changed, 65 insertions, 107 deletions
diff --git a/man.c b/man.c
index 7046d57d..191afdd5 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.162 2015/04/23 15:35:59 schwarze Exp $ */
+/* $Id: man.c,v 1.163 2015/04/23 16:17:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -318,49 +318,3 @@ man_mparse(const struct roff_man *man)
assert(man && man->parse);
return(man->parse);
}
-
-void
-man_deroff(char **dest, const struct roff_node *n)
-{
- char *cp;
- size_t sz;
-
- if (n->type != ROFFT_TEXT) {
- for (n = n->child; n; n = n->next)
- man_deroff(dest, n);
- return;
- }
-
- /* Skip leading whitespace and escape sequences. */
-
- cp = n->string;
- while ('\0' != *cp) {
- if ('\\' == *cp) {
- cp++;
- mandoc_escape((const char **)&cp, NULL, NULL);
- } else if (isspace((unsigned char)*cp))
- cp++;
- else
- break;
- }
-
- /* Skip trailing whitespace. */
-
- for (sz = strlen(cp); sz; sz--)
- if (0 == isspace((unsigned char)cp[sz-1]))
- break;
-
- /* Skip empty strings. */
-
- if (0 == sz)
- return;
-
- if (NULL == *dest) {
- *dest = mandoc_strndup(cp, sz);
- return;
- }
-
- mandoc_asprintf(&cp, "%s %*s", *dest, (int)sz, cp);
- free(*dest);
- *dest = cp;
-}
diff --git a/man.h b/man.h
index 9e77eee4..249fbf94 100644
--- a/man.h
+++ b/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.74 2015/04/18 17:53:21 schwarze Exp $ */
+/* $Id: man.h,v 1.75 2015/04/23 16:17:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -64,6 +64,5 @@ __BEGIN_DECLS
struct roff_man;
const struct mparse *man_mparse(const struct roff_man *);
-void man_deroff(char **, const struct roff_node *);
__END_DECLS
diff --git a/mandocdb.c b/mandocdb.c
index 46bd4dfa..34d5e464 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.193 2015/04/18 17:53:21 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.194 2015/04/23 16:17:44 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -1476,7 +1476,7 @@ parse_man(struct mpage *mpage, const struct roff_meta *meta,
*/
title = NULL;
- man_deroff(&title, body);
+ deroff(&title, body);
if (NULL == title)
return;
@@ -1720,7 +1720,7 @@ parse_mdoc_Nd(struct mpage *mpage, const struct roff_meta *meta,
{
if (n->type == ROFFT_BODY)
- mdoc_deroff(&mpage->desc, n);
+ deroff(&mpage->desc, n);
return(0);
}
diff --git a/mdoc.c b/mdoc.c
index 7fad2cff..a48dc223 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.251 2015/04/23 15:35:59 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.252 2015/04/23 16:17:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -507,42 +507,3 @@ mdoc_isdelim(const char *p)
return(DELIM_NONE);
}
-
-void
-mdoc_deroff(char **dest, const struct roff_node *n)
-{
- char *cp;
- size_t sz;
-
- if (n->type != ROFFT_TEXT) {
- for (n = n->child; n; n = n->next)
- mdoc_deroff(dest, n);
- return;
- }
-
- /* Skip leading whitespace. */
-
- for (cp = n->string; '\0' != *cp; cp++)
- if (0 == isspace((unsigned char)*cp))
- break;
-
- /* Skip trailing whitespace. */
-
- for (sz = strlen(cp); sz; sz--)
- if (0 == isspace((unsigned char)cp[sz-1]))
- break;
-
- /* Skip empty strings. */
-
- if (0 == sz)
- return;
-
- if (NULL == *dest) {
- *dest = mandoc_strndup(cp, sz);
- return;
- }
-
- mandoc_asprintf(&cp, "%s %*s", *dest, (int)sz, cp);
- free(*dest);
- *dest = cp;
-}
diff --git a/mdoc.h b/mdoc.h
index ddfd4e1e..30f60fab 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.141 2015/04/18 17:53:21 schwarze Exp $ */
+/* $Id: mdoc.h,v 1.142 2015/04/23 16:17:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -279,11 +279,3 @@ extern const char *const *mdoc_macronames;
/* Names of macro args. Index is enum mdocargt. */
extern const char *const *mdoc_argnames;
-
-__BEGIN_DECLS
-
-struct roff_man;
-
-void mdoc_deroff(char **, const struct roff_node *);
-
-__END_DECLS
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 272c23aa..1b3cbef3 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.290 2015/04/20 09:48:53 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.291 2015/04/23 16:17:44 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -969,7 +969,7 @@ post_nm(POST_ARGS)
if (NULL != mdoc->meta.name)
return;
- mdoc_deroff(&mdoc->meta.name, n);
+ deroff(&mdoc->meta.name, n);
if (NULL == mdoc->meta.name)
mandoc_msg(MANDOCERR_NM_NONAME, mdoc->parse,
@@ -1883,7 +1883,7 @@ post_sh_head(POST_ARGS)
secname = NULL;
sec = SEC_CUSTOM;
- mdoc_deroff(&secname, mdoc->last);
+ deroff(&secname, mdoc->last);
sec = NULL == secname ? SEC_CUSTOM : a2sec(secname);
/* The NAME should be first. */
@@ -2132,7 +2132,7 @@ post_dd(POST_ARGS)
}
datestr = NULL;
- mdoc_deroff(&datestr, n);
+ deroff(&datestr, n);
if (mdoc->quick)
mdoc->meta.date = datestr;
else {
@@ -2267,7 +2267,7 @@ post_os(POST_ARGS)
free(mdoc->meta.os);
mdoc->meta.os = NULL;
- mdoc_deroff(&mdoc->meta.os, n);
+ deroff(&mdoc->meta.os, n);
if (mdoc->meta.os)
goto out;
diff --git a/roff.c b/roff.c
index 6b50b518..94bcfa0e 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.268 2015/04/19 14:57:38 schwarze Exp $ */
+/* $Id: roff.c,v 1.269 2015/04/23 16:17:44 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -1230,6 +1230,52 @@ roff_node_delete(struct roff_man *man, struct roff_node *n)
roff_node_free(n);
}
+void
+deroff(char **dest, const struct roff_node *n)
+{
+ char *cp;
+ size_t sz;
+
+ if (n->type != ROFFT_TEXT) {
+ for (n = n->child; n != NULL; n = n->next)
+ deroff(dest, n);
+ return;
+ }
+
+ /* Skip leading whitespace and escape sequences. */
+
+ cp = n->string;
+ while (*cp != '\0') {
+ if ('\\' == *cp) {
+ cp++;
+ mandoc_escape((const char **)&cp, NULL, NULL);
+ } else if (isspace((unsigned char)*cp))
+ cp++;
+ else
+ break;
+ }
+
+ /* Skip trailing whitespace. */
+
+ for (sz = strlen(cp); sz; sz--)
+ if ( ! isspace((unsigned char)cp[sz-1]))
+ break;
+
+ /* Skip empty strings. */
+
+ if (sz == 0)
+ return;
+
+ if (*dest == NULL) {
+ *dest = mandoc_strndup(cp, sz);
+ return;
+ }
+
+ mandoc_asprintf(&cp, "%s %*s", *dest, (int)sz, cp);
+ free(*dest);
+ *dest = cp;
+}
+
/* --- main functions of the roff parser ---------------------------------- */
/*
diff --git a/roff.h b/roff.h
index cf29d6d1..750ccbe2 100644
--- a/roff.h
+++ b/roff.h
@@ -157,3 +157,9 @@ struct roff_man {
enum roff_sec lastnamed; /* Last standard section seen. */
enum roff_next next; /* Where to put the next node. */
};
+
+__BEGIN_DECLS
+
+void deroff(char **, const struct roff_node *);
+
+__END_DECLS