diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-20 22:55:46 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-20 22:55:46 +0000 |
commit | e2762e29b6445ab6177b83521a279938a317605f (patch) | |
tree | f1daca9b424eb34693a3cb687aa7dba20226f4b0 /action.c | |
parent | 7a6aee8ed3dc388c63c4711e3a8122b46d8740fb (diff) | |
download | mandoc-e2762e29b6445ab6177b83521a279938a317605f.tar.gz |
Added regression tests (just for prologue, for now).
Minor fixes in parsing prologue.
Diffstat (limited to 'action.c')
-rw-r--r-- | action.c | 41 |
1 files changed, 9 insertions, 32 deletions
@@ -246,6 +246,8 @@ post_dt(struct mdoc *mdoc) if (NULL == mdoc->meta.title) mdoc->meta.title = xstrdup("untitled"); + mdoc_msg(mdoc, "title: %s", mdoc->meta.title); + return(post_prologue(mdoc)); } @@ -279,46 +281,21 @@ post_os(struct mdoc *mdoc) static int post_dd(struct mdoc *mdoc) { - char date[64]; - size_t sz; - char *p; - struct mdoc_node *n; + char buf[64]; assert(MDOC_ELEM == mdoc->last->type); assert(MDOC_Dd == mdoc->last->tok); - n = mdoc->last->child; assert(0 == mdoc->meta.date); - date[0] = 0; - - sz = 64; - - for ( ; 0 == mdoc->meta.date && n; n = n->next) { - assert(MDOC_TEXT == n->type); - p = n->data.text.string; - if (xstrcmp(p, "$Mdocdate$")) { - mdoc->meta.date = time(NULL); - continue; - } else if (xstrcmp(p, "$")) { - mdoc->meta.date = mdoc_atotime(date); - continue; - } else if (xstrcmp(p, "$Mdocdate:")) - continue; + if ( ! xstrlcats(buf, mdoc->last->child, 64)) + return(mdoc_err(mdoc, "macro parameters too long")); + if (0 == (mdoc->meta.date = mdoc_atotime(buf))) + return(mdoc_err(mdoc, "invalid parameter syntax")); - if ( ! xstrlcat(date, n->data.text.string, sz)) - return(mdoc_nerr(mdoc, n, "invalid parameter syntax")); - if (n->next && ! xstrlcat(date, " ", sz)) - return(mdoc_nerr(mdoc, n, "invalid parameter syntax")); - } + mdoc_msg(mdoc, "date: %u", mdoc->meta.date); - if (mdoc->meta.date && NULL == n) - return(post_prologue(mdoc)); - else if (n) - return(mdoc_err(mdoc, "invalid parameter syntax")); - if ((mdoc->meta.date = mdoc_atotime(date))) - return(post_prologue(mdoc)); - return(mdoc_err(mdoc, "invalid parameter syntax")); + return(post_prologue(mdoc)); } |