Bruce Korb <[EMAIL PROTECTED]> writes:

> 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.

But the GNU coding standards say that programs generally must treat
NUL bytes as valid data.  There might be some minor benefit to
appending a NUL, but since a program should handle internal NUL
anyway, it'll need to check against the file size anyway.

I've sometimes felt the need for mapping a text file into memory,
and adding a trailing \n if the file ends in an incomplete line.
I suppose that might be a useful module for GNU programs.

An argument against using mmap is that input (e.g., EIO) errors
typically cause signals to be sent to your program, and it's a pain to
catch them and do the right thing portably.


Reply via email to