X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fclosein.c;h=2a652f4940a1bb9d84459a06f7781c940dad0ffc;hb=5b9e0c3ce734b9d9b0c0001e31b65a8a4713700d;hp=8b4bf09e2549cc66a494aeca96de4365c76981cc;hpb=3030c5b5e0a5199e16b05927da72c43c42f211c3;p=gnulib.git diff --git a/lib/closein.c b/lib/closein.c index 8b4bf09e2..2a652f494 100644 --- a/lib/closein.c +++ b/lib/closein.c @@ -1,6 +1,6 @@ /* Close standard input, rewinding seekable stdin if necessary. - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -55,7 +55,7 @@ close_stdin_set_file_name (const char *file) For example, POSIX requires that these two commands behave alike: (sed -ne 1q; cat) < file - tail -n 1 file + tail -n +2 file Since close_stdin is commonly registered via 'atexit', POSIX and the C standard both say that it should not call 'exit', @@ -82,7 +82,8 @@ close_stdin (void) /* There is no need to flush stdin if we can determine quickly that stdin's input buffer is empty; in this case we know that if stdin is seekable, - fseeko (stdin, 0, SEEK_CUR) == lseek (0, 0, SEEK_CUR). */ + (fseeko (stdin, 0, SEEK_CUR), ftello (stdin)) + == lseek (0, 0, SEEK_CUR). */ if (freadahead (stdin) > 0) { /* Only attempt flush if stdin is seekable, as fflush is entitled to