=================================================================== RCS file: /cvs/mandoc/mdoc_macro.c,v retrieving revision 1.53 retrieving revision 1.56 diff -u -p -r1.53 -r1.56 --- mandoc/mdoc_macro.c 2010/05/07 05:34:56 1.53 +++ mandoc/mdoc_macro.c 2010/05/07 05:54:09 1.56 @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.53 2010/05/07 05:34:56 kristaps Exp $ */ +/* $Id: mdoc_macro.c,v 1.56 2010/05/07 05:54:09 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -623,7 +623,7 @@ static int append_delims(struct mdoc *mdoc, int line, int *pos, char *buf) { int lastarg; - enum margerr ac; + enum margserr ac; char *p; if (0 == buf[*pos]) @@ -654,7 +654,7 @@ static int blk_exp_close(MACRO_PROT_ARGS) { int j, lastarg, maxargs, flushed; - enum margerr ac; + enum margserr ac; enum mdoct ntok; char *p; @@ -702,19 +702,22 @@ blk_exp_close(MACRO_PROT_ARGS) if (ARGS_EOLN == ac) break; - if (MDOC_MAX != (ntok = lookup(tok, p))) { - if ( ! flushed) { - if ( ! rew_sub(MDOC_BLOCK, m, tok, line, ppos)) - return(0); - flushed = 1; - } - if ( ! mdoc_macro(m, ntok, line, lastarg, pos, buf)) + ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); + + if (MDOC_MAX == ntok) { + if ( ! mdoc_word_alloc(m, line, lastarg, p)) return(0); - break; - } + continue; + } - if ( ! mdoc_word_alloc(m, line, lastarg, p)) + if ( ! flushed) { + if ( ! rew_sub(MDOC_BLOCK, m, tok, line, ppos)) + return(0); + flushed = 1; + } + if ( ! mdoc_macro(m, ntok, line, lastarg, pos, buf)) return(0); + break; } if ( ! flushed && ! rew_sub(MDOC_BLOCK, m, tok, line, ppos)) @@ -729,9 +732,10 @@ blk_exp_close(MACRO_PROT_ARGS) static int in_line(MACRO_PROT_ARGS) { - int la, lastpunct, c, cnt, d, nc; + int la, lastpunct, cnt, d, nc; + enum margverr av; enum mdoct ntok; - enum margerr ac; + enum margserr ac; struct mdoc_arg *arg; char *p; @@ -761,15 +765,15 @@ in_line(MACRO_PROT_ARGS) for (arg = NULL;; ) { la = *pos; - c = mdoc_argv(m, line, tok, &arg, pos, buf); + av = mdoc_argv(m, line, tok, &arg, pos, buf); - if (ARGV_WORD == c) { + if (ARGV_WORD == av) { *pos = la; break; } - if (ARGV_EOLN == c) + if (ARGV_EOLN == av) break; - if (ARGV_ARG == c) + if (ARGV_ARG == av) continue; mdoc_argv_free(arg); @@ -787,8 +791,6 @@ in_line(MACRO_PROT_ARGS) if (ARGS_PUNCT == ac) break; - /* Quoted words shouldn't be looked-up. */ - ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); /* @@ -882,7 +884,7 @@ in_line(MACRO_PROT_ARGS) static int blk_full(MACRO_PROT_ARGS) { - int c, la; + int la; struct mdoc_arg *arg; struct mdoc_node *head; /* save of head macro */ struct mdoc_node *body; /* save of body macro */ @@ -890,7 +892,8 @@ blk_full(MACRO_PROT_ARGS) struct mdoc_node *n; #endif enum mdoct ntok; - enum margerr ac; + enum margserr ac; + enum margverr av; char *p; /* Close out prior implicit scope. */ @@ -913,16 +916,16 @@ blk_full(MACRO_PROT_ARGS) for (arg = NULL;; ) { la = *pos; - c = mdoc_argv(m, line, tok, &arg, pos, buf); + av = mdoc_argv(m, line, tok, &arg, pos, buf); - if (ARGV_WORD == c) { + if (ARGV_WORD == av) { *pos = la; break; } - if (ARGV_EOLN == c) + if (ARGV_EOLN == av) break; - if (ARGV_ARG == c) + if (ARGV_ARG == av) continue; mdoc_argv_free(arg); @@ -985,7 +988,9 @@ blk_full(MACRO_PROT_ARGS) continue; } - if (MDOC_MAX == (ntok = lookup(tok, p))) { + ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); + + if (MDOC_MAX == ntok) { if ( ! mdoc_word_alloc(m, line, la, p)) return(0); continue; @@ -1044,7 +1049,7 @@ blk_part_imp(MACRO_PROT_ARGS) { int la; enum mdoct ntok; - enum margerr ac; + enum margserr ac; char *p; struct mdoc_node *blk; /* saved block context */ struct mdoc_node *body; /* saved body context */ @@ -1101,7 +1106,9 @@ blk_part_imp(MACRO_PROT_ARGS) body = m->last; } - if (MDOC_MAX == (ntok = lookup(tok, p))) { + ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); + + if (MDOC_MAX == ntok) { if ( ! mdoc_word_alloc(m, line, la, p)) return(0); continue; @@ -1154,7 +1161,7 @@ static int blk_part_exp(MACRO_PROT_ARGS) { int la; - enum margerr ac; + enum margserr ac; struct mdoc_node *head; /* keep track of head */ struct mdoc_node *body; /* keep track of body */ char *p; @@ -1223,7 +1230,9 @@ blk_part_exp(MACRO_PROT_ARGS) assert(NULL != head && NULL != body); - if (MDOC_MAX == (ntok = lookup(tok, p))) { + ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); + + if (MDOC_MAX == ntok) { if ( ! mdoc_word_alloc(m, line, la, p)) return(0); continue; @@ -1262,8 +1271,9 @@ blk_part_exp(MACRO_PROT_ARGS) static int in_line_argn(MACRO_PROT_ARGS) { - int la, flushed, j, c, maxargs; - enum margerr ac; + int la, flushed, j, maxargs; + enum margserr ac; + enum margverr av; struct mdoc_arg *arg; char *p; enum mdoct ntok; @@ -1296,16 +1306,16 @@ in_line_argn(MACRO_PROT_ARGS) for (arg = NULL; ; ) { la = *pos; - c = mdoc_argv(m, line, tok, &arg, pos, buf); + av = mdoc_argv(m, line, tok, &arg, pos, buf); - if (ARGV_WORD == c) { + if (ARGV_WORD == av) { *pos = la; break; } - if (ARGV_EOLN == c) + if (ARGV_EOLN == av) break; - if (ARGV_ARG == c) + if (ARGV_ARG == av) continue; mdoc_argv_free(arg); @@ -1339,7 +1349,9 @@ in_line_argn(MACRO_PROT_ARGS) flushed = 1; } - if (MDOC_MAX != (ntok = lookup(tok, p))) { + ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); + + if (MDOC_MAX != ntok) { if ( ! flushed && ! rew_elem(m, tok)) return(0); flushed = 1; @@ -1395,8 +1407,9 @@ in_line_argn(MACRO_PROT_ARGS) static int in_line_eoln(MACRO_PROT_ARGS) { - int c, la; - enum margerr ac; + int la; + enum margserr ac; + enum margverr av; struct mdoc_arg *arg; char *p; enum mdoct ntok; @@ -1407,15 +1420,15 @@ in_line_eoln(MACRO_PROT_ARGS) for (arg = NULL; ; ) { la = *pos; - c = mdoc_argv(m, line, tok, &arg, pos, buf); + av = mdoc_argv(m, line, tok, &arg, pos, buf); - if (ARGV_WORD == c) { + if (ARGV_WORD == av) { *pos = la; break; } - if (ARGV_EOLN == c) + if (ARGV_EOLN == av) break; - if (ARGV_ARG == c) + if (ARGV_ARG == av) continue; mdoc_argv_free(arg); @@ -1498,7 +1511,7 @@ static int phrase(struct mdoc *m, int line, int ppos, char *buf) { int la, pos; - enum margerr ac; + enum margserr ac; enum mdoct ntok; char *p;