summaryrefslogtreecommitdiffstats
path: root/roff.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2008-12-03 19:21:58 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2008-12-03 19:21:58 +0000
commitc67723cb5220a19191e6836e53b8d0a489c86797 (patch)
treee75720ca8fbbb4d7f4a0ed25af3ab2b2ecf392b3 /roff.c
parentac4bc07079be4963163734d67749697140f23b4b (diff)
downloadmandoc-c67723cb5220a19191e6836e53b8d0a489c86797.tar.gz
Major update.
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c109
1 files changed, 23 insertions, 86 deletions
diff --git a/roff.c b/roff.c
index dcb37567..310a91e2 100644
--- a/roff.c
+++ b/roff.c
@@ -134,9 +134,9 @@ static int roffcall(struct rofftree *, int, char **);
static int roffparse(struct rofftree *, char *);
static int textparse(const struct rofftree *, char *);
-#ifdef __linux__ /* FIXME: remove */
-static size_t strlcat(char *, const char *, size_t);
-static size_t strlcpy(char *, const char *, size_t);
+#ifdef __linux__
+extern size_t strlcat(char *, const char *, size_t);
+extern size_t strlcpy(char *, const char *, size_t);
extern int vsnprintf(char *, size_t,
const char *, va_list);
extern char *strptime(const char *, const char *,
@@ -1227,6 +1227,8 @@ roff_layout(ROFFCALL_ARGS)
return(0);
} else if (ROFF_EXIT == type) {
roffnode_free(tree);
+ if ( ! (*tree->cb.roffblkbodyout)(tree->arg, tok))
+ return(0);
return((*tree->cb.roffblkout)(tree->arg, tok));
}
@@ -1248,8 +1250,10 @@ roff_layout(ROFFCALL_ARGS)
if ( ! (*tree->cb.roffblkin)(tree->arg, tok, argcp, argvp))
return(0);
if (NULL == *argv)
- return(1);
- if ( ! (*tree->cb.roffin)(tree->arg, tok, argcp, argvp))
+ return((*tree->cb.roffblkbodyin)
+ (tree->arg, tok, argcp, argvp));
+
+ if ( ! (*tree->cb.roffblkheadin)(tree->arg, tok, argcp, argvp))
return(0);
/*
@@ -1264,7 +1268,10 @@ roff_layout(ROFFCALL_ARGS)
return(0);
i = 1;
}
- return((*tree->cb.roffout)(tree->arg, tok));
+ if ( ! (*tree->cb.roffblkheadout)(tree->arg, tok))
+ return(0);
+ return((*tree->cb.roffblkbodyin)
+ (tree->arg, tok, argcp, argvp));
}
/*
@@ -1293,8 +1300,12 @@ roff_layout(ROFFCALL_ARGS)
* macro.
*/
- if (NULL == *argv)
- return((*tree->cb.roffout)(tree->arg, tok));
+ if (NULL == *argv) {
+ if ( ! (*tree->cb.roffblkheadout)(tree->arg, tok))
+ return(0);
+ return((*tree->cb.roffblkbodyin)
+ (tree->arg, tok, argcp, argvp));
+ }
/*
* Expensive. Scan to the end of line then work backwards until
@@ -1304,7 +1315,10 @@ roff_layout(ROFFCALL_ARGS)
if ( ! roffpurgepunct(tree, argv))
return(0);
- return((*tree->cb.roffout)(tree->arg, tok));
+ if ( ! (*tree->cb.roffblkheadout)(tree->arg, tok))
+ return(0);
+ return((*tree->cb.roffblkbodyin)
+ (tree->arg, tok, argcp, argvp));
}
@@ -1445,80 +1459,3 @@ roff_err(const struct rofftree *tree, const char *pos, char *fmt, ...)
ROFF_ERROR, tree->cur, pos, buf);
}
-
-#ifdef __linux /* FIXME: remove. */
-/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
-
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all
- * copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
- * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-static size_t
-strlcat(char *dst, const char *src, size_t siz)
-{
- char *d = dst;
- const char *s = src;
- size_t n = siz;
- size_t dlen;
-
- /* Find the end of dst and adjust bytes left but don't go past
- * end */
- while (n-- != 0 && *d != '\0')
- d++;
- dlen = d - dst;
- n = siz - dlen;
-
- if (n == 0)
- return(dlen + strlen(s));
- while (*s != '\0') {
- if (n != 1) {
- *d++ = *s;
- n--;
- }
- s++;
- }
- *d = '\0';
-
- return(dlen + (s - src)); /* count does not include NUL */
-}
-
-
-static size_t
-strlcpy(char *dst, const char *src, size_t siz)
-{
- char *d = dst;
- const char *s = src;
- size_t n = siz;
-
- /* Copy as many bytes as will fit */
- if (n != 0) {
- while (--n != 0) {
- if ((*d++ = *s++) == '\0')
- break;
- }
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
-}
-#endif /*__linux__*/