This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: text file formats

On Thu, Apr 06, 2006 at 06:43:48AM +0300, Eli Zaretskii wrote:
> > Date: Wed, 5 Apr 2006 18:31:22 -0400
> > From: Bob Rossi <>
> > 
> > However, it is easy to mix these file formats. In this case, any particular 
> > file can use any combination of "\r", "\r\n" and "\n" for newlines. I'm not 
> > even sure how to display such a file. I'm guessing that's it's
> > ambiguous, and i can make a best guess as to what the newline sequence
> > should be. Is this correct?
> > 
> > One thing I have determined, is that in order to know what the file
> > format is, the entire text file needs to be parsed. After that, either
> > the file format is defined (unix/dos/mac) or it is undefined (mix of
> > them).
> (a) For native end-of-line (EOL) format, use the native C library and
>     specify the text-mode I/O when you open the file.
> (b) For non-native but consistent EOL format, read the file in binary
>     mode, analyze its first chunk, and then manually convert the
>     original EOL markers into literal \n.

OK, that's fine, except, you don't know if the file is native/non-native
EOL until you open it and process the entire file.

> The only two methods I know of to handle the mixed case are:
>   (1) Fall back to Unix-style EOL and show the ^M literally.

>   (2) Let the user specify the EOL and then apply the (b) strategy
>       above.

OK, that's fine, but is this what GDB, GCC do?

Bob Rossi

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]