comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst-u@mib.org>
Subject: Re: Text IO for files not using the standard line termination for the OS
Date: Sat, 17 Nov 2018 20:40:24 -0800
Date: 2018-11-17T20:40:24-08:00	[thread overview]
Message-ID: <lny39rq9qf.fsf@kst-u.example.com> (raw)
In-Reply-To: c84ae1bf-c589-463c-ae41-e8faa4928169@googlegroups.com

jdgressett@hotmail.com writes:
> I use Ada 2012 to write Windows programs; my usual compiler is 32-bit
> TDM-gcc which implements the gcc-5.1.0 version of the Ada compiler.
>
> My problem is a simple one: i need to produce a program which reads
> lines from a text file; if a line meets a requirement, it is written
> to an output file; if it does not meet the requirement it is not
> written to the output file.
>
> The annoyance that I must deal with is the fact that the files are not
> Windows text files, which use the <cr><lf> convention to terminate
> text lines.
>
> The files use a single <cr> as the line terminator.

That's unusual.  The most recent system system I know of that uses that
representation is pre-OSX MacOS.

> Is there a way to get Ada.Text_IO to use a line terminator that is not
> the default for the operation system on which the program runs?

There's no standard way to do it.  GNAT does provide some non-standard
Form parameters for Text_IO.Create and Text_IO.Open, but none of then do
just what you want.  ("Text_Translation=No" would let you handle
Unix-style text files on Windows, with line endings marked by <lf>.)

http://docs.adacore.com/live/wave/gnat_rm/html/gnat_rm/gnat_rm/the_implementation_of_standard_i_o.html#text-translation

Your best bet might be to translate the files before you feed them to
your program.  Or you can read the files in binary mode.

-- 
Keith Thompson (The_Other_Keith) kst@mib.org  <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

  parent reply	other threads:[~2018-11-18  4:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-18  2:01 Text IO for files not using the standard line termination for the OS jdgressett
2018-11-18  3:44 ` Shark8
2018-11-18  9:26   ` Jeffrey R. Carter
2018-11-18 23:41     ` jdgressett
2018-11-18  4:40 ` Keith Thompson [this message]
2018-11-18 10:10   ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox