bug-ed
[Top][All Lists]
Advanced

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

[Bug-ed] Removed funny behavior on EOF


From: Andrea Monaco
Subject: [Bug-ed] Removed funny behavior on EOF
Date: Tue, 8 Jan 2013 22:09:57 +0100

diff --git a/io.c b/io.c
index 68956e1..820df15 100644
--- a/io.c
+++ b/io.c
@@ -134,7 +134,7 @@ const char * get_tty_line( int * const sizep )
   {
   static char * buf = 0;
   static int bufsz = 0;
-  int i = 0, oi = -1;
+  int i = 0;
 
   while( true )
     {
@@ -149,8 +149,9 @@ const char * get_tty_line( int * const sizep )
         }
       else
         {
-        clearerr( stdin ); if( i != oi ) { oi = i; continue; }
-        if( i ) buf[i] = 0; if( sizep ) *sizep = i;
+        clearerr( stdin );
+ /* when possible, it's better to put a null character */
+        if( bufsz > i ) buf[i] = 0; if( sizep ) *sizep = i;
         return buf;
         }
       }

reply via email to

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