Hi, It has always been an irritant that you cannot mmap a text file and be sure that there is a terminating NUL, without going to a lot of hassle. The attached gnulib module goes to all the trouble necessary. It uses mmap(2) on all systems that have it and does a malloc/open/read/close/free sequence for those that don't.
Using it, I am able to map a text file and run strlen() on the data mapped in, even when the file size is an exact multiple of the page size. However, "make check" does not seem to do anything for me. Is there yet magic to be written? For your amusement or incorporation. - Bruce $ tar cvf - */*text-mmap* |gzip --best > text-mmap.tgz lib/text-mmap.c lib/text-mmap.h m4/text-mmap.m4 modules/text-mmap modules/text-mmap-tests tests/test-text-mmap.c tests/test-text-mmap.sh
text-mmap.tgz
Description: application/compressed-tar