# HG changeset patch # User Eric Blake # Date 1304358072 21600 # Node ID ead32d10a3f020e60844f53079759e62f3e622f0 # Parent d214c42cc3febaa28e26821f17f9b490aa353875 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 diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2011-05-02 Eric Blake + fclose: reduced dependencies + * modules/fclose (Depends-on): Switch from fflush/fseeko to + simpler lseek. + * lib/fclose.c (rpl_fclose): Likewise. + Reported by Simon Josefsson. + exit: drop remaining clients * modules/argmatch (Depends-on): Replace exit with stdlib. * modules/copy-file (Depends-on): Likewise. diff --git a/lib/fclose.c b/lib/fclose.c --- a/lib/fclose.c +++ b/lib/fclose.c @@ -33,8 +33,10 @@ 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) diff --git a/modules/fclose b/modules/fclose --- a/modules/fclose +++ b/modules/fclose @@ -8,9 +8,8 @@ Depends-on: stdio close -fflush freading -fseeko +lseek configure.ac: gl_FUNC_FCLOSE