[hackers] [sbase] Don't overwrite the line buffer when we hit EOF on one of the files in comm(1) || sin

From: <git_AT_suckless.org>
Date: Thu, 13 Nov 2014 17:01:57 +0100

commit 519a4f810563ac018a72b694c24f96db6f7c7152
Author: sin <sin_AT_2f30.org>
Date: Thu Nov 13 15:55:02 2014 +0000

    Don't overwrite the line buffer when we hit EOF on one of the files in comm(1)

diff --git a/comm.c b/comm.c
index 0cf3d41..d2a5a21 100644
--- a/comm.c
+++ b/comm.c
_AT_@ -49,14 +49,20 @@ main(int argc, char *argv[])
 
         for(;;) {
                 if(diff <= 0) {
+ lines[0][0] = '\0';
                         if(!nextline(lines[0], sizeof(lines[0]),
                                      fp[0], argv[0])) {
+ if (lines[1][0] != '\0')
+ printline(1, lines[1]);
                                 finish(1, fp[1], argv[1]);
                         }
                 }
                 if(diff >= 0) {
+ lines[1][0] = '\0';
                         if(!nextline(lines[1], sizeof(lines[1]),
                                      fp[1], argv[1])) {
+ if (lines[0][0] != '\0')
+ printline(0, lines[0]);
                                 finish(0, fp[0], argv[0]);
                         }
                 }
Received on Thu Nov 13 2014 - 17:01:57 CET

This archive was generated by hypermail 2.3.0 : Thu Nov 13 2014 - 17:12:14 CET