=================================================================== RCS file: /cvs/mandoc/man_macro.c,v retrieving revision 1.57 retrieving revision 1.62 diff -u -p -r1.57 -r1.62 --- mandoc/man_macro.c 2011/03/20 16:02:05 1.57 +++ mandoc/man_macro.c 2011/04/19 16:38:48 1.62 @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.57 2011/03/20 16:02:05 kristaps Exp $ */ +/* $Id: man_macro.c,v 1.62 2011/04/19 16:38:48 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -23,6 +23,7 @@ #include #include +#include "man.h" #include "mandoc.h" #include "libmandoc.h" #include "libman.h" @@ -37,6 +38,8 @@ static int blk_close(MACRO_PROT_ARGS); static int blk_exp(MACRO_PROT_ARGS); static int blk_imp(MACRO_PROT_ARGS); static int in_line_eoln(MACRO_PROT_ARGS); +static int man_args(struct man *, int, + int *, char *, char **); static int rew_scope(enum man_type, struct man *, enum mant); @@ -295,7 +298,7 @@ blk_close(MACRO_PROT_ARGS) int blk_exp(MACRO_PROT_ARGS) { - int w, la; + int la; char *p; /* @@ -316,13 +319,8 @@ blk_exp(MACRO_PROT_ARGS) for (;;) { la = *pos; - w = man_args(m, line, pos, buf, &p); - - if (-1 == w) - return(0); - if (0 == w) + if ( ! man_args(m, line, pos, buf, &p)) break; - if ( ! man_word_alloc(m, line, la, p)) return(0); } @@ -347,7 +345,7 @@ blk_exp(MACRO_PROT_ARGS) int blk_imp(MACRO_PROT_ARGS) { - int w, la; + int la; char *p; struct man_node *n; @@ -371,13 +369,8 @@ blk_imp(MACRO_PROT_ARGS) for (;;) { la = *pos; - w = man_args(m, line, pos, buf, &p); - - if (-1 == w) - return(0); - if (0 == w) + if ( ! man_args(m, line, pos, buf, &p)) break; - if ( ! man_word_alloc(m, line, la, p)) return(0); } @@ -405,7 +398,7 @@ blk_imp(MACRO_PROT_ARGS) int in_line_eoln(MACRO_PROT_ARGS) { - int w, la; + int la; char *p; struct man_node *n; @@ -416,11 +409,7 @@ in_line_eoln(MACRO_PROT_ARGS) for (;;) { la = *pos; - w = man_args(m, line, pos, buf, &p); - - if (-1 == w) - return(0); - if (0 == w) + if ( ! man_args(m, line, pos, buf, &p)) break; if ( ! man_word_alloc(m, line, la, p)) return(0); @@ -483,3 +472,18 @@ man_macroend(struct man *m) return(man_unscope(m, m->first, MANDOCERR_SCOPEEXIT)); } +static int +man_args(struct man *m, int line, int *pos, char *buf, char **v) +{ + char *start; + + assert(*pos); + *v = start = buf + *pos; + assert(' ' != *start); + + if ('\0' == *start) + return(0); + + *v = mandoc_getarg(m->parse, v, line, pos); + return(1); +}