summaryrefslogtreecommitdiff
path: root/lib/fclose.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-05-02 11:41:12 -0600
committerEric Blake <eblake@redhat.com>2011-05-02 15:23:42 -0600
commit001e7d63dfe613e249e9f4ab53170b401532afd3 (patch)
treeb1d97f54a736fa247549af3d21212cdc2e319800 /lib/fclose.c
parent0fc0aa38149cc8d1b35537c56ea5d0b83eadcf56 (diff)
downloadgnulib-001e7d63dfe613e249e9f4ab53170b401532afd3.tar.gz
fclose: reduce dependencies
In an LGPLv2+ project, the last change to fclose dragged in inappropriate modules. * modules/fclose (Depends-on): Switch from fflush/fseeko to simpler lseek. * lib/fclose.c (rpl_fclose): Likewise. Reported by Simon Josefsson. Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'lib/fclose.c')
-rw-r--r--lib/fclose.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/fclose.c b/lib/fclose.c
index bce409c960..c8c2fd8e4c 100644
--- a/lib/fclose.c
+++ b/lib/fclose.c
@@ -33,8 +33,10 @@ rpl_fclose (FILE *fp)
int saved_errno = 0;
/* We only need to flush the file if it is not reading or if it is
- seekable. */
- if ((!freading (fp) || fseeko (fp, 0, SEEK_CUR) == 0) && fflush (fp))
+ seekable. This only guarantees the file position of input files
+ if the fflush module is also in use. */
+ if ((!freading (fp) || lseek (fileno (fp), 0, SEEK_CUR) != -1)
+ && fflush (fp))
saved_errno = errno;
if (close (fileno (fp)) < 0 && saved_errno == 0)