H
Hallvard B Furuseth
I'm trying to clean up a program which does arithmetic on text
file positions, and also reads text files in binary mode. I
can't easily get rid of it all, so I'm wondering which of the
following assumptions are, well, least unportable.
In particular, do anyone know if there are real-life systems
where the text file assumptions below don't hold?
For text mode FILE*s,
* input lines will be ordered by ftell() position, and one can
do arithmetic on ftell() positions within one line. I.e.:
- getc() adds 1 to the ftell() position, except possibly at
the end of a line and EOF.
- at the end of a line, getc() increments the position with a
small positive number. (Or moderately small, if the file
consists of fixed-size space-padded line records.)
Or for binary mode FILE*s,
* getc() data looks like it does from a text mode FILE*, except:
- lines end with CR/LF/CRLF/LFCR, maybe preceded with spaces.
(Fails for fixed-size line records, I know. Or lines stored
as <length, contents>, if there are such files around.)
- files end at EOF or with ^Z (yuck). Or maybe that should be
"a byte < 32 for which isspace()==0". I can assume ASCII or
a superset, otherwise the file must be preprocessed anyway.
file positions, and also reads text files in binary mode. I
can't easily get rid of it all, so I'm wondering which of the
following assumptions are, well, least unportable.
In particular, do anyone know if there are real-life systems
where the text file assumptions below don't hold?
For text mode FILE*s,
* input lines will be ordered by ftell() position, and one can
do arithmetic on ftell() positions within one line. I.e.:
- getc() adds 1 to the ftell() position, except possibly at
the end of a line and EOF.
- at the end of a line, getc() increments the position with a
small positive number. (Or moderately small, if the file
consists of fixed-size space-padded line records.)
Or for binary mode FILE*s,
* getc() data looks like it does from a text mode FILE*, except:
- lines end with CR/LF/CRLF/LFCR, maybe preceded with spaces.
(Fails for fixed-size line records, I know. Or lines stored
as <length, contents>, if there are such files around.)
- files end at EOF or with ^Z (yuck). Or maybe that should be
"a byte < 32 for which isspace()==0". I can assume ASCII or
a superset, otherwise the file must be preprocessed anyway.