=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_macro.c,v retrieving revision 1.33 retrieving revision 1.34 diff -c -r1.33 -r1.34 *** src/usr.bin/mandoc/mdoc_macro.c 2010/04/02 11:39:00 1.33 --- src/usr.bin/mandoc/mdoc_macro.c 2010/04/02 12:39:47 1.34 *************** *** 1,4 **** ! /* $Id: mdoc_macro.c,v 1.33 2010/04/02 11:39:00 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * --- 1,4 ---- ! /* $Id: mdoc_macro.c,v 1.34 2010/04/02 12:39:47 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * *************** *** 38,50 **** static int blk_part_imp(MACRO_PROT_ARGS); static int phrase(struct mdoc *, int, int, char *); ! static int rew_dohalt(int, enum mdoc_type, const struct mdoc_node *); ! static int rew_alt(int); ! static int rew_dobreak(int, const struct mdoc_node *); ! static int rew_elem(struct mdoc *, int); static int rew_sub(enum mdoc_type, struct mdoc *, ! int, int, int); static int rew_last(struct mdoc *, const struct mdoc_node *); static int append_delims(struct mdoc *, int, int *, char *); --- 38,50 ---- static int blk_part_imp(MACRO_PROT_ARGS); static int phrase(struct mdoc *, int, int, char *); ! static int rew_dohalt(enum mdoct, enum mdoc_type, const struct mdoc_node *); ! static enum mdoct rew_alt(enum mdoct); ! static int rew_dobreak(enum mdoct, const struct mdoc_node *); ! static int rew_elem(struct mdoc *, enum mdoct); static int rew_sub(enum mdoc_type, struct mdoc *, ! enum mdoct, int, int); static int rew_last(struct mdoc *, const struct mdoc_node *); static int append_delims(struct mdoc *, int, int *, char *); *************** *** 315,322 **** * Return the opening macro of a closing one, e.g., `Ec' has `Eo' as its * matching pair. */ ! static int ! rew_alt(int tok) { switch (tok) { case (MDOC_Ac): --- 315,322 ---- * Return the opening macro of a closing one, e.g., `Ec' has `Eo' as its * matching pair. */ ! static enum mdoct ! rew_alt(enum mdoct tok) { switch (tok) { case (MDOC_Ac): *************** *** 366,372 **** * The scope-closing and so on occurs in the various rew_* routines. */ static int ! rew_dohalt(int tok, enum mdoc_type type, const struct mdoc_node *p) { if (MDOC_ROOT == p->type) --- 366,373 ---- * The scope-closing and so on occurs in the various rew_* routines. */ static int ! rew_dohalt(enum mdoct tok, enum mdoc_type type, ! const struct mdoc_node *p) { if (MDOC_ROOT == p->type) *************** *** 505,511 **** * REWIND_NOHALT). */ static int ! rew_dobreak(int tok, const struct mdoc_node *p) { assert(MDOC_ROOT != p->type); --- 506,512 ---- * REWIND_NOHALT). */ static int ! rew_dobreak(enum mdoct tok, const struct mdoc_node *p) { assert(MDOC_ROOT != p->type); *************** *** 534,540 **** return(1); break; case (MDOC_Oc): - /* XXX - experimental! */ if (MDOC_Op == p->tok) return(1); break; --- 535,540 ---- *************** *** 552,558 **** static int ! rew_elem(struct mdoc *mdoc, int tok) { struct mdoc_node *n; --- 552,558 ---- static int ! rew_elem(struct mdoc *mdoc, enum mdoct tok) { struct mdoc_node *n; *************** *** 568,574 **** static int rew_sub(enum mdoc_type t, struct mdoc *m, ! int tok, int line, int ppos) { struct mdoc_node *n; int c; --- 568,574 ---- static int rew_sub(enum mdoc_type t, struct mdoc *m, ! enum mdoct tok, int line, int ppos) { struct mdoc_node *n; int c; *************** *** 596,605 **** return(0); /* ! * The current block extends an enclosing block beyond a line break. ! * Now that the current block ends, close the enclosing block, too. */ ! if ((n = n->pending) != NULL) { assert(MDOC_HEAD == n->type); if ( ! rew_last(m, n)) return(0); --- 596,606 ---- return(0); /* ! * The current block extends an enclosing block beyond a line ! * break. Now that the current block ends, close the enclosing ! * block, too. */ ! if (NULL != (n = n->pending)) { assert(MDOC_HEAD == n->type); if ( ! rew_last(m, n)) return(0); *************** *** 872,877 **** --- 873,879 ---- int c, la; struct mdoc_arg *arg; struct mdoc_node *head; /* save of head macro */ + struct mdoc_node *body; /* save of body macro */ struct mdoc_node *n; char *p; *************** *** 914,920 **** if ( ! mdoc_block_alloc(m, line, ppos, tok, arg)) return(0); ! head = NULL; /* * The `Nd' macro has all arguments in its body: it's a hybrid --- 916,922 ---- if ( ! mdoc_block_alloc(m, line, ppos, tok, arg)) return(0); ! head = body = NULL; /* * The `Nd' macro has all arguments in its body: it's a hybrid *************** *** 929,934 **** --- 931,937 ---- return(0); if ( ! mdoc_body_alloc(m, line, ppos, tok)) return(0); + body = m->last; } for (;;) { *************** *** 991,1009 **** if (1 == ppos && ! append_delims(m, line, pos, buf)) return(0); ! /* See notes on `Nd' hybrid, above. */ ! if (MDOC_Nd == tok) return(1); /* ! * If there is an open sub-block requiring explicit close-out, ! * postpone switching the current block from head to body ! * until the rew_sub() call closing out that sub-block. */ for (n = m->last; n && n != head; n = n->parent) { ! if (MDOC_BLOCK == n->type && ! MDOC_EXPLICIT & mdoc_macros[n->tok].flags) { n->pending = head; return(1); } --- 994,1015 ---- if (1 == ppos && ! append_delims(m, line, pos, buf)) return(0); ! /* If we've already opened our body, exit now. */ ! if (NULL != body) return(1); /* ! * If there is an open (i.e., unvalidated) sub-block requiring ! * explicit close-out, postpone switching the current block from ! * head to body until the rew_sub() call closing out that ! * sub-block. */ for (n = m->last; n && n != head; n = n->parent) { ! if (MDOC_BLOCK == n->type && ! MDOC_EXPLICIT & mdoc_macros[n->tok].flags && ! ! (MDOC_VALID & n->flags)) { ! assert( ! (MDOC_ACTED & n->flags)); n->pending = head; return(1); } *************** *** 1106,1114 **** * If we can't rewind to our body, then our scope has already * been closed by another macro (like `Oc' closing `Op'). This * is ugly behaviour nodding its head to OpenBSD's overwhelming ! * crufty use of `Op' breakage. XXX: DEPRECATE. */ - for (n = m->last; n; n = n->parent) if (body == n) break; --- 1112,1119 ---- * If we can't rewind to our body, then our scope has already * been closed by another macro (like `Oc' closing `Op'). This * is ugly behaviour nodding its head to OpenBSD's overwhelming ! * crufty use of `Op' breakage. */ for (n = m->last; n; n = n->parent) if (body == n) break;