delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/11/16:17:25

Date: Tue, 11 Apr 2000 13:42:45 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Bharat Mallapur <bharatmallapur AT eth DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: Ansi/iso C compliance whatever it may eventually mean
In-Reply-To: <002301bfa351$9c3bb3a0$2d9709ca@saraswati>
Message-ID: <Pine.SUN.3.91.1000411134221.4929R-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 11 Apr 2000, Bharat Mallapur wrote:

> in short i want to know that how is it that gcc which is supposed to be
> "totally" ansi/iso compliant not have getchar which is a standard library
> function.

I think you misunderstood what the GCC maintainers told you.  What
they tell you is that the library you are using is a separate product:
it was written specifically for the DJGPP project.  The compiler
itself comes with no library.

In other words, the GCC maintainers simply told you that you were
posting your question to the wrong news group.  See section 20.1 of
the DJGPP FAQ list for more about this.

> The fact is i decided to download djgpp only after being told on comp.lang.c
> that it is a fully ansi/iso compliant compiler and of course that it is
> free.
>  So now please tell me whether djgpp is ansi/iso C compliant or not.

DJGPP is ANSI/ISO compliant, at least as far as the C89 standard is
concerned (in contrast, C99 is not fully supported yet).

>>My problem is the following:
>>============================
>>/*
>> Problem : Non leading EOF is ignored by getchar().
>> Triggering :
>>             Try TYPING IN the 3 following lines when running the program:
>>             "a ^Z the" enter/return
>>             " ^Z the"  enter/return
>>             "^Z the"   enter/return
>>             (here ^Z gives EOF and is same as Ctrl+Z)

This is not a bug.  (It certainly isn't an ANSI compatibility issue,
since the ANSI standard doesn't say anything about the ^Z character.)

The problem with your program is that it uses (the default) buffered
I/O to read single characters from the console device.  In buffered
operation, the DJGPP library removes the ^Z characters from the
stream, so that they don't end up in the application buffer.  That's
why you don't see the EOF where you expect it.

The simplest change that will make your program behave as you want is
to add the following line before the loop:

 setvbuf (stdin, NULL, _IONBF, 0);

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019