aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/strings.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-01-20 22:55:46 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-01-20 22:55:46 +0000
commit8c93af8e9eb62eb23b9862156fbb36edd225ed36 (patch)
treef7d458624e88d7c3e4c76fd3d0e224029fb4f872 /strings.c
parentc4da36392950a99306bb7aae41a441fdf8e9f48f (diff)
downloadmandoc-8c93af8e9eb62eb23b9862156fbb36edd225ed36.tar.gz
mandoc-8c93af8e9eb62eb23b9862156fbb36edd225ed36.tar.zst
mandoc-8c93af8e9eb62eb23b9862156fbb36edd225ed36.zip
Added regression tests (just for prologue, for now).
Minor fixes in parsing prologue.
Diffstat (limited to 'strings.c')
-rw-r--r--strings.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/strings.c b/strings.c
index d655677b..77312258 100644
--- a/strings.c
+++ b/strings.c
@@ -1,4 +1,4 @@
-/* $Id: strings.c,v 1.10 2009/01/20 13:49:36 kristaps Exp $ */
+/* $Id: strings.c,v 1.11 2009/01/20 22:55:46 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -124,12 +124,18 @@ time_t
mdoc_atotime(const char *p)
{
struct tm tm;
+ char *pp;
(void)memset(&tm, 0, sizeof(struct tm));
- if (0 == strptime(p, "%b %d %Y", &tm))
+ if (xstrcmp(p, "$Mdocdate: January 20 2009 $"))
+ return(time(NULL));
+ if ((pp = strptime(p, "$Mdocdate: January 20 2009 $", &tm)) && 0 == *pp)
return(mktime(&tm));
- if (0 == strptime(p, "%b %d, %Y", &tm))
+ /* XXX - this matches "June 1999", which is wrong. */
+ if ((pp = strptime(p, "%b %d %Y", &tm)) && 0 == *pp)
+ return(mktime(&tm));
+ if ((pp = strptime(p, "%b %d, %Y", &tm)) && 0 == *pp)
return(mktime(&tm));
return(0);