summaryrefslogtreecommitdiffstats
path: root/mandoc.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-07-24 18:15:13 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-07-24 18:15:13 +0000
commit9d40bd2a7ce3100befc3054237b3cb3a8bc9777d (patch)
tree3da90ac84a9ba5f4aa9e551ab6e61969d88b7cd7 /mandoc.c
parent0db02e2364d93cad88a1df785984438635066e39 (diff)
downloadmandoc-9d40bd2a7ce3100befc3054237b3cb3a8bc9777d.tar.gz
Scary-looking but otherwise harmless changes allow me to build for Windows.
That is to say, with mingw32. This amounts to the following: (1) break compat.c into compat_strlcpy.c and compat_strlcat.c (2) add compat_getsubopt.c (from OpenBSD) and test-getsubopt.c (3) add test-strptime.c for HAVE_STRPTIME (4) add ifdef bits here and there, where necessary (5) remove some harmless unportable stuff (u_char, localtime_r) I've added the appropriate mdocml.zip target to the Makefile, too.
Diffstat (limited to 'mandoc.c')
-rw-r--r--mandoc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/mandoc.c b/mandoc.c
index 0f8e5394..c08465ff 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -542,7 +542,10 @@ a2time(time_t *t, const char *fmt, const char *p)
memset(&tm, 0, sizeof(struct tm));
+ pp = NULL;
+#ifdef HAVE_STRPTIME
pp = strptime(p, fmt, &tm);
+#endif
if (NULL != pp && '\0' == *pp) {
*t = mktime(&tm);
return(1);
@@ -554,12 +557,12 @@ a2time(time_t *t, const char *fmt, const char *p)
static char *
time2a(time_t t)
{
- struct tm tm;
+ struct tm *tm;
char *buf, *p;
size_t ssz;
int isz;
- localtime_r(&t, &tm);
+ tm = localtime(&t);
/*
* Reserve space:
@@ -569,15 +572,15 @@ time2a(time_t t)
*/
p = buf = mandoc_malloc(10 + 4 + 4 + 1);
- if (0 == (ssz = strftime(p, 10 + 1, "%B ", &tm)))
+ if (0 == (ssz = strftime(p, 10 + 1, "%B ", tm)))
goto fail;
p += (int)ssz;
- if (-1 == (isz = snprintf(p, 4 + 1, "%d, ", tm.tm_mday)))
+ if (-1 == (isz = snprintf(p, 4 + 1, "%d, ", tm->tm_mday)))
goto fail;
p += isz;
- if (0 == strftime(p, 4 + 1, "%Y", &tm))
+ if (0 == strftime(p, 4 + 1, "%Y", tm))
goto fail;
return(buf);