Mail Archives: djgpp/1996/10/23/02:29:17
Some times ago I had the same problem:
Developping a small compiler I used a big file as a source library.
When I encountered an include statement within a module, I used
to save the actual position with ftell(), reading the included
module and at the end of this I used fseek to resume reading
at the proper place.
I had a first problem with a module in the library containing
a single cr (0x0D). This seems to disturb all compilers I used
(Borland C++, Visual C++ and djgpp). After fixing it (replacing
it by blank in the file) all worked good with Borland C++ and
Visual C++, but I still had problems with djgpp.
The final solution was to use different FILE variables reopening
the library file for each include and avoiding pairing of ftell/fseek.
The troubles caused by the presence of the character 0x0D are dued
to the fact that the ftell routine counts the presence of single
chars and not pairs of cr/lf. But, as the different documentations
warns about malfunctioning in case of presence of nonprintable characters
in text files, this may be ok.
In each case now I always try to avoid the usage of ftell/fseek in
conjunction with DOS text files.
Daniel
- Raw text -