From d5899efe4a68c00b14f7b4e40042b60c86db4898 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Sun, 24 Jul 2011 18:15:13 +0000 Subject: 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. --- preconv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'preconv.c') diff --git a/preconv.c b/preconv.c index a53504ec..a0b2d641 100644 --- a/preconv.c +++ b/preconv.c @@ -1,4 +1,4 @@ -/* $Id: preconv.c,v 1.4 2011/05/26 21:13:07 kristaps Exp $ */ +/* $Id: preconv.c,v 1.5 2011/07/24 18:15:14 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * @@ -18,8 +18,10 @@ #include "config.h" #endif +#ifdef HAVE_MMAP #include #include +#endif #include #include @@ -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) -- cgit v1.2.3-56-ge451