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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8d5bda3619cce0f8,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.glorb.com!news2.glorb.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Date: Mon, 16 Feb 2009 21:36:01 +0100 From: Thomas Locke User-Agent: Thunderbird 2.0.0.19 (X11/20081209) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: C getchar() functionality in Ada Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4999ce31$0$90266$14726298@news.sunsite.dk> Organization: SunSITE.dk - Supporting Open source NNTP-Posting-Host: 83.91.213.86 X-Trace: news.sunsite.dk DXC=BIN\J]945aF3j@n`X75YjCYSB=nbEKnkKL?8>K\5E[IK]KcSoP8OK@H@kCUDmHHZ?E:WTk`c[X5;OBJES Hey all, I've started redoing all the K&R C examples in Ada, and I've already hit a wall that I'm not able to get around. I have this C program: http://pastebin.com/fbc6bec5 It's very simple, but still I fail to mimick it in Ada. The C program happily accepts everything I throw at it, and it responds with the expected values, whereas my Ada version(s) either fail at linefeeds, throw End_Error exceptions at me, or spits out too many linefeeds! My current Ada code looks like this: http://pastebin.com/f519f7e37 This version works with input from keyboard and when I pipe some data into it like this: $ echo "FooBar" | ito It craps out on files ($ cat SomeFile | ito), where it ignores linefeeds and throws End_Error exceptions at me when the last character in the file is a linefeed I've tried with Get_Immediate, Look_Ahead, Get_Line and a mixture of Strings, Characters and Unbounded strings. I just can't make it work. Any and all advice are more than welcome. :o) /Thomas