bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: sed bug on seekable stdin


From: Paolo Bonzini
Subject: Re: sed bug on seekable stdin
Date: Sun, 17 Dec 2006 10:36:17 +0100
User-agent: Thunderbird 1.5.0.8 (Macintosh/20061025)


The solution is simple - before any use of exit(EXIT_SUCCESS) (or before
returning from main), you must ensure that you call fclose(stdin).

Can you check out the attached patch on CVS or 4.1b sed?

Thanks,

Paolo
--- orig/sed/utils.c
+++ mod/sed/utils.c
@@ -328,6 +328,15 @@ ck_fclose(stream)
     {
       do_ck_fclose (stdout);
       do_ck_fclose (stderr);
+
+      /* When a standard utility reads a seekable input file and terminates
+        without an error before it reaches end-of-file, the utility shall 
ensure
+        that the file offset in the open file description is properly 
positioned
+        just past the last byte processed by the utility.  */
+
+      fflush(stdin);
+      fseek(stdin, 0, SEEK_CUR);
+      fclose(stdin);
     }
 }
 

reply via email to

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