diff options
author | 2011-01-16 02:56:47 +0000 | |
---|---|---|
committer | 2011-01-16 02:56:47 +0000 | |
commit | aad3ea0cf9a80eeddbd69941824fa913eaa077f5 (patch) | |
tree | 805a454b0d7cefde822d4d059eaa9e85d2a227e3 /usr.bin/mandoc/man.c | |
parent | Various tbl improvements from kristaps@: (diff) | |
download | wireguard-openbsd-aad3ea0cf9a80eeddbd69941824fa913eaa077f5.tar.xz wireguard-openbsd-aad3ea0cf9a80eeddbd69941824fa913eaa077f5.zip |
If the first character of a free-form text input line is whitespace,
then it will start a new output line;
from kristaps@.
Diffstat (limited to 'usr.bin/mandoc/man.c')
-rw-r--r-- | usr.bin/mandoc/man.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c index 09d79242b7c..dd39e73d8ef 100644 --- a/usr.bin/mandoc/man.c +++ b/usr.bin/mandoc/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.53 2011/01/09 13:16:48 schwarze Exp $ */ +/* $Id: man.c,v 1.54 2011/01/16 02:56:47 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -40,7 +40,7 @@ const char *const __man_macronames[MAN_MAX] = { const char * const *man_macronames = __man_macronames; -static struct man_node *man_node_alloc(int, int, +static struct man_node *man_node_alloc(struct man *, int, int, enum man_type, enum mant); static int man_node_append(struct man *, struct man_node *); @@ -125,6 +125,8 @@ int man_parseln(struct man *m, int ln, char *buf, int offs) { + m->flags |= MAN_NEWLINE; + assert( ! (MAN_HALT & m->flags)); return(('.' == buf[offs] || '\'' == buf[offs]) ? man_pmacro(m, ln, buf, offs) : @@ -225,7 +227,8 @@ man_node_append(struct man *man, struct man_node *p) static struct man_node * -man_node_alloc(int line, int pos, enum man_type type, enum mant tok) +man_node_alloc(struct man *m, int line, int pos, + enum man_type type, enum mant tok) { struct man_node *p; @@ -234,6 +237,10 @@ man_node_alloc(int line, int pos, enum man_type type, enum mant tok) p->pos = pos; p->type = type; p->tok = tok; + + if (MAN_NEWLINE & m->flags) + p->flags |= MAN_LINE; + m->flags &= ~MAN_NEWLINE; return(p); } @@ -243,7 +250,7 @@ man_elem_alloc(struct man *m, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(line, pos, MAN_ELEM, tok); + p = man_node_alloc(m, line, pos, MAN_ELEM, tok); if ( ! man_node_append(m, p)) return(0); m->next = MAN_NEXT_CHILD; @@ -256,7 +263,7 @@ man_head_alloc(struct man *m, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(line, pos, MAN_HEAD, tok); + p = man_node_alloc(m, line, pos, MAN_HEAD, tok); if ( ! man_node_append(m, p)) return(0); m->next = MAN_NEXT_CHILD; @@ -269,7 +276,7 @@ man_body_alloc(struct man *m, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(line, pos, MAN_BODY, tok); + p = man_node_alloc(m, line, pos, MAN_BODY, tok); if ( ! man_node_append(m, p)) return(0); m->next = MAN_NEXT_CHILD; @@ -282,7 +289,7 @@ man_block_alloc(struct man *m, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(line, pos, MAN_BLOCK, tok); + p = man_node_alloc(m, line, pos, MAN_BLOCK, tok); if ( ! man_node_append(m, p)) return(0); m->next = MAN_NEXT_CHILD; @@ -295,7 +302,7 @@ man_span_alloc(struct man *m, const struct tbl_span *span) struct man_node *n; /* FIXME: grab from span */ - n = man_node_alloc(0, 0, MAN_TBL, MAN_MAX); + n = man_node_alloc(m, 0, 0, MAN_TBL, MAN_MAX); n->span = span; if ( ! man_node_append(m, n)) @@ -313,7 +320,7 @@ man_word_alloc(struct man *m, int line, int pos, const char *word) len = strlen(word); - n = man_node_alloc(line, pos, MAN_TEXT, MAN_MAX); + n = man_node_alloc(m, line, pos, MAN_TEXT, MAN_MAX); n->string = mandoc_malloc(len + 1); sv = strlcpy(n->string, word, len + 1); |