comp.lang.ada
 help / color / mirror / Atom feed
From: David Starner <dstarner98@aasaa.ofe.org>
Subject: Unix text handling on stdin
Date: 24 Aug 2001 21:36:19 GMT
Date: 2001-08-24T21:36:19+00:00	[thread overview]
Message-ID: <9m6hcj$aai1@news.cis.okstate.edu> (raw)

I've worked on a couple things where I've had problems with this,
so I'd figure I'd ask it here. How do I read in a text file from
stdin as text, do some analysis on it, and then spit it out binary
identical version of stdout? That is, every form-feed (probably
interpreted as a new page by Ada.Text_IO), every carriage return,
every line feed in the original exists in the output in the exact 
same place; likewise the present or absences of a trailing LF or CRLF.

The problems I had, were:

(a) Ada.Text_IO will happily munch a form feed in such a way that 
it's hard to tell whether we had a form feed or new line. 

(b) From my reading, it's entirely standards-compliant to treat LF and 
CRLF the same way on Unix; it would certainly simplify things. This is 
a theoritical problem for me, as GNAT doesn't do this.

(c) GNAT would always terminate the output with a new line when the
program ended. (This was serious problem when I was trying to write
up a submission for the latest ICFP. The output couldn't be larger
than the input; but if the input was minimal and had no trailing
newline, the trailing newline would cause the program to lose.)

I understand that Ada.Text_IO is supposed to be portable; but I need
it to work in a system correct way more than I need it to be portable.
Is there any maximally standards complaint way to solve this? How about
'it should work on any reasonable compiler' way? GNAT specific way will
work; restricting myself to GNAT on Linux is not much different than just
restricting myself to Linux.

-- 
David Starner - dstarner98@aasaa.ofe.org
Pointless website: http://dvdeug.dhis.org
"I don't care if Bill personally has my name and reads my email and 
laughs at me. In fact, I'd be rather honored." - Joseph_Greg



             reply	other threads:[~2001-08-24 21:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-24 21:36 David Starner [this message]
2001-08-24 23:44 ` Unix text handling on stdin sk
2001-08-25  2:56 ` sk
replies disabled

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