version 1.5, 2011/07/24 18:15:14 |
version 1.6, 2013/06/02 03:52:21 |
|
|
|
|
/* |
/* |
* The read_whole_file() and resize_buf() functions are copied from |
* The read_whole_file() and resize_buf() functions are copied from |
* read.c, including all dependency code (MAP_FILE, etc.). |
* read.c, including all dependency code. |
*/ |
*/ |
|
|
#ifndef MAP_FILE |
|
#define MAP_FILE 0 |
|
#endif |
|
|
|
enum enc { |
enum enc { |
ENC_UTF_8, /* UTF-8 */ |
ENC_UTF_8, /* UTF-8 */ |
ENC_US_ASCII, /* US-ASCII */ |
ENC_US_ASCII, /* US-ASCII */ |
Line 271 read_whole_file(const char *f, int fd, |
|
Line 267 read_whole_file(const char *f, int fd, |
|
if (S_ISREG(st.st_mode)) { |
if (S_ISREG(st.st_mode)) { |
*with_mmap = 1; |
*with_mmap = 1; |
fb->sz = (size_t)st.st_size; |
fb->sz = (size_t)st.st_size; |
fb->buf = mmap(NULL, fb->sz, PROT_READ, |
fb->buf = mmap(NULL, fb->sz, PROT_READ, MAP_SHARED, fd, 0); |
MAP_FILE|MAP_SHARED, fd, 0); |
|
if (fb->buf != MAP_FAILED) |
if (fb->buf != MAP_FAILED) |
return(1); |
return(1); |
} |
} |