diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-16 19:08:11 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-16 19:08:11 +0000 |
commit | 2c1a869d51c44602bea55601bfc78b354fe539ae (patch) | |
tree | a589d907774e05ea5432db36f6825fd9210aa04a /roff.c | |
parent | edfe20876cb0a4f5dafff7c44b921b4a5a8c5830 (diff) | |
download | mandoc-2c1a869d51c44602bea55601bfc78b354fe539ae.tar.gz mandoc-2c1a869d51c44602bea55601bfc78b354fe539ae.tar.zst mandoc-2c1a869d51c44602bea55601bfc78b354fe539ae.zip |
Regression tests in place for `.if' in libroff.
Check against some strange `.if' constructs I missed.
Added initial roff.7 manual.
Diffstat (limited to 'roff.c')
-rw-r--r-- | roff.c | 35 |
1 files changed, 30 insertions, 5 deletions
@@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.76 2010/05/16 14:47:19 kristaps Exp $ */ +/* $Id: roff.c,v 1.77 2010/05/16 19:08:11 kristaps Exp $ */ /* * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -381,7 +381,9 @@ roff_ig(ROFF_ARGS) ROFF_MDEBUG(r, "opening ignore block"); - /* FIXME: warn about end of line. */ + if ((*bufp)[pos]) + if ( ! (*r->msg)(MANDOCERR_ARGSLOST, r->data, ln, pos, NULL)) + return(ROFF_ERR); return(ROFF_IGN); } @@ -391,6 +393,7 @@ roff_ig(ROFF_ARGS) static enum rofferr roff_if(ROFF_ARGS) { + int sv; /* * Read ahead past the conditional. @@ -399,14 +402,29 @@ roff_if(ROFF_ARGS) * It's good enough for now, however. */ - if ( ! roffnode_push(r, tok, ln, ppos)) - return(ROFF_ERR); - while ((*bufp)[pos] && ' ' != (*bufp)[pos]) pos++; + + sv = pos; while (' ' == (*bufp)[pos]) pos++; + /* + * Roff is weird. If we have just white-space after the + * conditional, it's considered the BODY and we exit without + * really doing anything. Warn about this. It's probably + * wrong. + */ + + if ('\0' == (*bufp)[pos] && sv != pos) { + if ( ! (*r->msg)(MANDOCERR_NOARGS, r->data, ln, ppos, NULL)) + return(ROFF_ERR); + return(ROFF_IGN); + } + + if ( ! roffnode_push(r, tok, ln, ppos)) + return(ROFF_ERR); + /* Don't evaluate: just assume NO. */ r->last->endspan = 1; @@ -418,9 +436,16 @@ roff_if(ROFF_ARGS) } else ROFF_MDEBUG(r, "opening implicit scope"); + /* + * If there are no arguments on the line, the next-line scope is + * assumed. + */ + if ('\0' == (*bufp)[pos]) return(ROFF_IGN); + /* Otherwise re-run the roff parser after recalculating. */ + *offs = pos; return(ROFF_RERUN); } |