bug-ed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-ed] Removed funny behavior on EOF


From: Antonio Diaz Diaz
Subject: Re: [Bug-ed] Removed funny behavior on EOF
Date: Thu, 10 Jan 2013 18:53:22 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.7.11) Gecko/20050905

This is the same change I planned to do. :-)


Andrea Monaco wrote:
+ /* when possible, it's better to put a null character */
+        if( bufsz > i ) buf[i] = 0; if( sizep ) *sizep = i;

"resize_buffer" can be moved to the top of the loop so that it is always possible to put a null character.

OTOH, I read this in the glibc manual:

"Most errors that can happen are not recoverable -- a second try will
always fail again in the same way.  So usually it is best to give up and
report the error to the user, rather than install complicated recovery
logic.

   One important exception is `EINTR' (*note Interrupted Primitives::).
Many stream I/O implementations will treat it as an ordinary error,
which can be quite inconvenient.  You can avoid this hassle by
installing all signals with the `SA_RESTART' flag."


So maybe the "double EOF" is there to handle an interrupted "getchar", in which case we should leave it alone.


Regards,
Antonio.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]