From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: Text IO for files not using the standard line termination for the OS Date: Sat, 17 Nov 2018 20:40:24 -0800 Organization: None to speak of Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader01.eternal-september.org; posting-host="0d00af7abad0798ed385984c7e8197c7"; logging-data="9453"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183LFAW/3CIZqNp/71qEX8z" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:CNthbWcFsSxhyXcOT+IeXYIk488= sha1:tSKkYP+/Pl9yxV4qi5HzweuV5LQ= Xref: reader01.eternal-september.org comp.lang.ada:54839 Date: 2018-11-17T20:40:24-08:00 List-Id: 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 convention to terminate > text lines. > > The files use a single 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 .) 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 Will write code for food. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"