=================================================================== RCS file: /cvs/mandoc/roff.c,v retrieving revision 1.47 retrieving revision 1.50 diff -u -p -r1.47 -r1.50 --- mandoc/roff.c 2008/12/06 21:10:31 1.47 +++ mandoc/roff.c 2008/12/07 22:40:18 1.50 @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.47 2008/12/06 21:10:31 kristaps Exp $ */ +/* $Id: roff.c,v 1.50 2008/12/07 22:40:18 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -640,6 +640,15 @@ roffspecial(struct rofftree *tree, int tok, const char break; roff_err(tree, start, "invalid `At' arg"); return(0); + + case (ROFF_Xr): + /* FALLTHROUGH */ + case (ROFF_Fn): + if (0 != sz) + break; + roff_err(tree, start, "`%s' expects at least " + "one arg", toknames[tok]); + return(0); case (ROFF_Nm): if (0 == sz) { @@ -653,15 +662,16 @@ roffspecial(struct rofftree *tree, int tok, const char return(0); break; + case (ROFF_Rv): + /* FALLTHROUGH*/ case (ROFF_Sx): /* FALLTHROUGH*/ case (ROFF_Ex): - if (1 != sz) { - roff_err(tree, start, "`%s' expects one arg", - toknames[tok]); - return(0); - } - break; + if (1 == sz) + break; + roff_err(tree, start, "`%s' expects one arg", + toknames[tok]); + return(0); case (ROFF_Sm): if (1 != sz) { @@ -691,8 +701,8 @@ roffspecial(struct rofftree *tree, int tok, const char break; } - return((*tree->cb.roffspecial)(tree->arg, tok, - tree->cur, argc, argv, ordp)); + return((*tree->cb.roffspecial)(tree->arg, tok, tree->cur, + argc, argv, (const char **)ordp)); } @@ -841,7 +851,7 @@ roff_Dd(ROFFCALL_ARGS) argv++; - if (0 == strcmp(*argv, "$Mdocdate: December 6 2008 $")) { + if (0 == strcmp(*argv, "$Mdocdate: December 7 2008 $")) { t = time(NULL); if (NULL == localtime_r(&t, &tree->tm)) err(1, "localtime_r"); @@ -1108,13 +1118,16 @@ roff_layout(ROFFCALL_ARGS) * the layout body is everything following until termination. */ - if ( ! (*tree->cb.roffblkin)(tree->arg, tok, argcp, argvp)) + if ( ! (*tree->cb.roffblkin)(tree->arg, tok, argcp, + (const char **)argvp)) return(0); if (NULL == *argv) return((*tree->cb.roffblkbodyin) - (tree->arg, tok, argcp, argvp)); + (tree->arg, tok, argcp, + (const char **)argvp)); - if ( ! (*tree->cb.roffblkheadin)(tree->arg, tok, argcp, argvp)) + if ( ! (*tree->cb.roffblkheadin)(tree->arg, tok, argcp, + (const char **)argvp)) return(0); /* @@ -1131,7 +1144,8 @@ roff_layout(ROFFCALL_ARGS) if ( ! (*tree->cb.roffblkheadout)(tree->arg, tok)) return(0); return((*tree->cb.roffblkbodyin) - (tree->arg, tok, argcp, argvp)); + (tree->arg, tok, argcp, + (const char **)argvp)); } /* @@ -1162,7 +1176,8 @@ roff_layout(ROFFCALL_ARGS) if ( ! (*tree->cb.roffblkheadout)(tree->arg, tok)) return(0); return((*tree->cb.roffblkbodyin) - (tree->arg, tok, argcp, argvp)); + (tree->arg, tok, argcp, + (const char **)argvp)); } /* @@ -1176,7 +1191,8 @@ roff_layout(ROFFCALL_ARGS) if ( ! (*tree->cb.roffblkheadout)(tree->arg, tok)) return(0); return((*tree->cb.roffblkbodyin) - (tree->arg, tok, argcp, argvp)); + (tree->arg, tok, argcp, + (const char **)argvp)); } @@ -1200,9 +1216,11 @@ roff_ordered(ROFFCALL_ARGS) if ( ! roffparseopts(tree, tok, &argv, argcp, argvp)) return(0); - if (NULL == *argv) + if (NULL == *argv) { + ordp[0] = NULL; return(roffspecial(tree, tok, p, argcp, (const char **)argvp, 0, ordp)); + } i = 0; while (*argv && i < ROFF_MAXLINEARG) { @@ -1261,7 +1279,8 @@ roff_text(ROFFCALL_ARGS) if ( ! roffparseopts(tree, tok, &argv, argcp, argvp)) return(0); - if ( ! (*tree->cb.roffin)(tree->arg, tok, argcp, argvp)) + if ( ! (*tree->cb.roffin)(tree->arg, tok, argcp, + (const char **)argvp)) return(0); if (NULL == *argv) return((*tree->cb.roffout)(tree->arg, tok)); @@ -1280,6 +1299,8 @@ roff_text(ROFFCALL_ARGS) * 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; @@ -1311,8 +1332,21 @@ roff_text(ROFFCALL_ARGS) 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, + (const char **)argvp)) + return(0); + + i = 0; continue; }