[GAP] LF to CR-LF

Robert Dewar dewar at adacore.com
Mon Aug 28 14:54:17 CEST 2006


Daniel Lewandowski wrote:

> I have in the file out.txt combination CR-LF instead of LF in the middle
> of printed line. At the end of the line I have of course CR-LF and this
> is a normal behaviour in Windows/DOS environment.

The effect of outputting a control character as part of a string
for text_io is implementation defined, so you can't expect any
specific behavior here.
>         
> Why is Text_IO changing LF into CR-LF in the middle of string?

Because by default Text_IO files are opened in the mode where the
OS changes any occurrence of LF to CR/LF, which seems to be the best
default choice. If you look at your program:

         procedure S is
            File : File_Type;
            Line : constant String := "ala ma" & Latin_1.Lf & " kota";
         begin
            Create (File => File, Name => "out.txt", Mode => Out_File);
            Put_Line (File => File, Item => Line);
            Close (File => File);
         end S;

On a Unix system this would create a standard format text file with
two lines. With the default interpretation we have chosen, this
program will have the same effect in a DOS type environment.

If we chose to output the LF on its own, the resulting file would not be
a standard format text file.

If you want the effect of LF's without CR's, you could get this by
manually opening the C stream with appropriate options, but then the
marker at the end of all lines would be simply LF.





More information about the GAP mailing list