-/* $OpenBSD: man.c,v 1.110 2015/04/23 15:35:39 schwarze Exp $ */
+/* $OpenBSD: man.c,v 1.111 2015/04/23 16:17:04 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
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;
-}
-/* $OpenBSD: man.h,v 1.54 2015/04/18 17:50:02 schwarze Exp $ */
+/* $OpenBSD: man.h,v 1.55 2015/04/23 16:17:04 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
struct roff_man;
const struct mparse *man_mparse(const struct roff_man *);
-void man_deroff(char **, const struct roff_node *);
__END_DECLS
-/* $OpenBSD: mandocdb.c,v 1.146 2015/04/18 17:50:02 schwarze Exp $ */
+/* $OpenBSD: mandocdb.c,v 1.147 2015/04/23 16:17:04 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
*/
title = NULL;
- man_deroff(&title, body);
+ deroff(&title, body);
if (NULL == title)
return;
{
if (n->type == ROFFT_BODY)
- mdoc_deroff(&mpage->desc, n);
+ deroff(&mpage->desc, n);
return(0);
}
-/* $OpenBSD: mdoc.c,v 1.140 2015/04/23 15:35:39 schwarze Exp $ */
+/* $OpenBSD: mdoc.c,v 1.141 2015/04/23 16:17:04 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
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;
-}
-/* $OpenBSD: mdoc.h,v 1.66 2015/04/18 17:50:02 schwarze Exp $ */
+/* $OpenBSD: mdoc.h,v 1.67 2015/04/23 16:17:04 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
/* 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
-/* $OpenBSD: mdoc_validate.c,v 1.206 2015/04/20 09:48:19 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.207 2015/04/23 16:17:04 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
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,
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. */
}
datestr = NULL;
- mdoc_deroff(&datestr, n);
+ deroff(&datestr, n);
if (mdoc->quick)
mdoc->meta.date = datestr;
else {
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;
-/* $OpenBSD: roff.c,v 1.140 2015/04/19 14:57:16 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.141 2015/04/23 16:17:04 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
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 ---------------------------------- */
/*
-/* $OpenBSD: roff.h,v 1.15 2015/04/19 13:59:37 schwarze Exp $ */
+/* $OpenBSD: roff.h,v 1.16 2015/04/23 16:17:04 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
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