[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mapping text files
From: |
Paul Eggert |
Subject: |
Re: Mapping text files |
Date: |
Sun, 17 Sep 2006 20:57:04 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
Bruce Korb <address@hidden> 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.