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: Bob Proulx
Subject: Re: sed bug on seekable stdin
Date: Sun, 17 Dec 2006 12:13:27 -0700
User-agent: Mutt/1.5.9i

Paolo Bonzini wrote:
> --- 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);

AFAIK fflush() is not needed in input streams as its purpose is to
flush pending output buffers and input streams have none.

> +      fseek(stdin, 0, SEEK_CUR);
> +      fclose(stdin);

How are I/O errors on stdin handled in this case?

>      }
>  }




reply via email to

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