-
-
-/* ARGSUSED */
-static int
-roff_text(ROFFCALL_ARGS)
-{
- int i, j, first, c, argcp[ROFF_MAXLINEARG];
- char *argvp[ROFF_MAXLINEARG];
-
- if (ROFF_PRELUDE & tree->state) {
- roff_err(tree, *argv, "`%s' disallowed in prelude",
- toknames[tok]);
- return(0);
- }
-
- first = (*argv == tree->cur);
- argv++;
-
- if ( ! roffparseopts(tree, tok, &argv, argcp, argvp))
- return(0);
- if ( ! (*tree->cb.roffin)(tree->arg, tok, argcp, argvp))
- return(0);
- if (NULL == *argv)
- return((*tree->cb.roffout)(tree->arg, tok));
-
- if ( ! (ROFF_PARSED & tokens[tok].flags)) {
- i = 0;
- while (*argv)
- if ( ! roffdata(tree, i++, *argv++))
- return(0);
-
- return((*tree->cb.roffout)(tree->arg, tok));
- }
-
- /*
- * Deal with punctuation. Ugly. Work ahead until we encounter
- * terminating punctuation. If we encounter it and all
- * subsequent tokens are punctuation, then stop processing (the
- * line-dominant macro will print these tokens after closure).
- * If the punctuation is followed by non-punctuation, then close
- * and re-open our scope, then continue.
- */
-
- i = 0;
- while (*argv) {
- if (ROFF_MAX != (c = rofffindcallable(*argv))) {
- if ( ! (ROFF_LSCOPE & tokens[tok].flags))
- if ( ! (*tree->cb.roffout)(tree->arg, tok))
- return(0);
-
- if ( ! roffcall(tree, c, argv))
- return(0);
-
- if (ROFF_LSCOPE & tokens[tok].flags)
- if ( ! (*tree->cb.roffout)(tree->arg, tok))
- return(0);
-
- break;
- }
-
- if ( ! roffispunct(*argv)) {
- if ( ! roffdata(tree, i++, *argv++))
- return(0);
- continue;
- }
-
- i = 1;
- for (j = 0; argv[j]; j++)
- if ( ! roffispunct(argv[j]))
- break;
-
- if (argv[j]) {
- if (ROFF_LSCOPE & tokens[tok].flags) {
- if ( ! roffdata(tree, 0, *argv++))
- return(0);
- continue;
- }
- if ( ! (*tree->cb.roffout)(tree->arg, tok))
- return(0);
- if ( ! roffdata(tree, 0, *argv++))
- return(0);
- if ( ! (*tree->cb.roffin)(tree->arg, tok,
- argcp, argvp))
- return(0);
-
- i = 0;
- continue;
- }
-
- if ( ! (*tree->cb.roffout)(tree->arg, tok))
- return(0);
- break;
- }
-
- if (NULL == *argv)
- return((*tree->cb.roffout)(tree->arg, tok));
- if ( ! first)
- return(1);
-
- return(roffpurgepunct(tree, argv));
-}
-
-
-/* ARGSUSED */
-static int
-roff_noop(ROFFCALL_ARGS)
-{
-
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-roff_depr(ROFFCALL_ARGS)
-{
-
- roff_err(tree, *argv, "`%s' is deprecated", toknames[tok]);
- return(0);
-}
-
-
-static void
-roff_warn(const struct rofftree *tree, const char *pos, char *fmt, ...)
-{
- va_list ap;
- char buf[128];
-
- va_start(ap, fmt);
- (void)vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
-
- (*tree->cb.roffmsg)(tree->arg,
- ROFF_WARN, tree->cur, pos, buf);
-}
-
-
-static void
-roff_err(const struct rofftree *tree, const char *pos, char *fmt, ...)
-{
- va_list ap;
- char buf[128];
-
- va_start(ap, fmt);
- (void)vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
-
- (*tree->cb.roffmsg)(tree->arg,
- ROFF_ERROR, tree->cur, pos, buf);
-}
-