summaryrefslogtreecommitdiffstats
path: root/preconv.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 /preconv.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 'preconv.c')
-rw-r--r--preconv.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/preconv.c b/preconv.c
index fcb50790..b2f031bc 100644
--- a/preconv.c
+++ b/preconv.c
@@ -18,8 +18,10 @@
#include "config.h"
#endif
+#ifdef HAVE_MMAP
#include <sys/stat.h>
#include <sys/mman.h>
+#endif
#include <assert.h>
#include <fcntl.h>
@@ -244,10 +246,11 @@ static int
read_whole_file(const char *f, int fd,
struct buf *fb, int *with_mmap)
{
- struct stat st;
size_t off;
ssize_t ssz;
+#ifdef HAVE_MMAP
+ struct stat st;
if (-1 == fstat(fd, &st)) {
perror(f);
return(0);
@@ -273,6 +276,7 @@ read_whole_file(const char *f, int fd,
if (fb->buf != MAP_FAILED)
return(1);
}
+#endif
/*
* If this isn't a regular file (like, say, stdin), then we must
@@ -510,9 +514,11 @@ main(int argc, char *argv[])
rc = EXIT_SUCCESS;
out:
+#ifdef HAVE_MMAP
if (map)
munmap(b.buf, b.sz);
else
+#endif
free(b.buf);
if (fd > STDIN_FILENO)