=================================================================== RCS file: /cvs/mandoc/man_macro.c,v retrieving revision 1.8 retrieving revision 1.18 diff -u -p -r1.8 -r1.18 --- mandoc/man_macro.c 2009/03/26 11:16:21 1.8 +++ mandoc/man_macro.c 2009/07/24 20:22:24 1.18 @@ -1,32 +1,58 @@ -/* $Id: man_macro.c,v 1.8 2009/03/26 11:16:21 kristaps Exp $ */ +/* $Id: man_macro.c,v 1.18 2009/07/24 20:22:24 kristaps Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the - * above copyright notice and this permission notice appear in all - * copies. + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE - * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include -#include #include #include "libman.h" +#define FL_NLINE (1 << 0) +#define FL_TLINE (1 << 1) + static int man_args(struct man *, int, int *, char *, char **); +static int man_flags[MAN_MAX] = { + 0, /* br */ + 0, /* TH */ + 0, /* SH */ + 0, /* SS */ + FL_TLINE, /* TP */ + 0, /* LP */ + 0, /* PP */ + 0, /* P */ + 0, /* IP */ + 0, /* HP */ + FL_NLINE, /* SM */ + FL_NLINE, /* SB */ + FL_NLINE, /* BI */ + FL_NLINE, /* IB */ + FL_NLINE, /* BR */ + FL_NLINE, /* RB */ + FL_NLINE, /* R */ + FL_NLINE, /* B */ + FL_NLINE, /* I */ + FL_NLINE, /* IR */ + FL_NLINE, /* RI */ + 0, /* na */ + FL_NLINE, /* i */ + 0, /* sp */ +}; int man_macro(struct man *man, int tok, int line, @@ -55,6 +81,20 @@ man_macro(struct man *man, int tok, int line, man->next = MAN_NEXT_SIBLING; } + if (n == man->last && (FL_NLINE & man_flags[tok])) { + if (MAN_NLINE & man->flags) + return(man_perr(man, line, ppos, WLNSCOPE)); + man->flags |= MAN_NLINE; + return(1); + } + + if (FL_TLINE & man_flags[tok]) { + if (MAN_NLINE & man->flags) + return(man_perr(man, line, ppos, WLNSCOPE)); + man->flags |= MAN_NLINE; + return(1); + } + /* * Note that when TH is pruned, we'll be back at the root, so * make sure that we don't clobber as its sibling. @@ -145,7 +185,7 @@ man_args(struct man *m, int line, if (buf[*pos]) return(1); - if ( ! man_vwarn(m, line, *pos, "trailing spaces")) + if ( ! man_pwarn(m, line, *pos, WTSPACE)) return(-1); return(1); @@ -163,7 +203,7 @@ man_args(struct man *m, int line, (*pos)++; if (0 == buf[*pos]) { - if ( ! man_vwarn(m, line, *pos, "unterminated quote")) + if ( ! man_pwarn(m, line, *pos, WTQUOTE)) return(-1); return(1); } @@ -178,7 +218,7 @@ man_args(struct man *m, int line, if (buf[*pos]) return(1); - if ( ! man_vwarn(m, line, *pos, "trailing spaces")) + if ( ! man_pwarn(m, line, *pos, WTSPACE)) return(-1); return(1); }