X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/cd17b00c20e30495d03c7e53adc3740d7be9b3cd..88fc6b869e3c723d6787f44989cf6139432fed70:/read.c diff --git a/read.c b/read.c index 9a1d9f37..da273ae1 100644 --- a/read.c +++ b/read.c @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.14 2011/04/30 10:18:24 kristaps Exp $ */ +/* $Id: read.c,v 1.15 2011/05/26 20:36:21 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -19,8 +19,10 @@ #include "config.h" #endif -#include -#include +#ifdef HAVE_MMAP +# include +# include +#endif #include #include @@ -529,19 +531,22 @@ pdesc(struct mparse *curp, const char *file, int fd) mparse_buf_r(curp, blk, 1); +#ifdef HAVE_MMAP if (with_mmap) munmap(blk.buf, blk.sz); else +#endif free(blk.buf); } static int read_whole_file(const char *file, 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(file); return(0); @@ -566,6 +571,7 @@ read_whole_file(const char *file, int fd, struct buf *fb, int *with_mmap) if (fb->buf != MAP_FAILED) return(1); } +#endif /* * If this isn't a regular file (like, say, stdin), then we must