version 1.14, 2011/04/30 10:18:24 |
version 1.15, 2011/05/26 20:36:21 |
|
|
#include "config.h" |
#include "config.h" |
#endif |
#endif |
|
|
#include <sys/stat.h> |
#ifdef HAVE_MMAP |
#include <sys/mman.h> |
# include <sys/stat.h> |
|
# include <sys/mman.h> |
|
#endif |
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
Line 529 pdesc(struct mparse *curp, const char *file, int fd) |
|
Line 531 pdesc(struct mparse *curp, const char *file, int fd) |
|
|
|
mparse_buf_r(curp, blk, 1); |
mparse_buf_r(curp, blk, 1); |
|
|
|
#ifdef HAVE_MMAP |
if (with_mmap) |
if (with_mmap) |
munmap(blk.buf, blk.sz); |
munmap(blk.buf, blk.sz); |
else |
else |
|
#endif |
free(blk.buf); |
free(blk.buf); |
} |
} |
|
|
static int |
static int |
read_whole_file(const char *file, int fd, struct buf *fb, int *with_mmap) |
read_whole_file(const char *file, int fd, struct buf *fb, int *with_mmap) |
{ |
{ |
struct stat st; |
|
size_t off; |
size_t off; |
ssize_t ssz; |
ssize_t ssz; |
|
|
|
#ifdef HAVE_MMAP |
|
struct stat st; |
if (-1 == fstat(fd, &st)) { |
if (-1 == fstat(fd, &st)) { |
perror(file); |
perror(file); |
return(0); |
return(0); |
Line 566 read_whole_file(const char *file, int fd, struct buf * |
|
Line 571 read_whole_file(const char *file, int fd, struct buf * |
|
if (fb->buf != MAP_FAILED) |
if (fb->buf != MAP_FAILED) |
return(1); |
return(1); |
} |
} |
|
#endif |
|
|
/* |
/* |
* If this isn't a regular file (like, say, stdin), then we must |
* If this isn't a regular file (like, say, stdin), then we must |