From ef5758c3282b3325340d8b601deed5ab5e7ade64 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 9 Apr 2010 10:49:38 +0200 Subject: maint: ftruncate is always available, even without gnulib Now that even MinGW provides ftruncate, we know that all reasonable portability targets provide this function. Remove the workaround code. We nearly removed the gnulib module three years ago: http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/9203 and it is now officially "obsolete". * bootstrap.conf (gnulib_modules): Remove ftruncate. * src/copy.c (copy_reg): Remove use of HAVE_FTRUNCATE and its no-longer-used workaround code. * src/truncate.c: Remove a comment about handling missing ftruncate. --- bootstrap.conf | 1 - src/copy.c | 10 ++-------- src/truncate.c | 7 +------ 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index 9cdf984ba..ad7d6d586 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -97,7 +97,6 @@ gnulib_modules=" fsusage fsync ftello - ftruncate fts getdate getgroups diff --git a/src/copy.c b/src/copy.c index 29f37c980..3c32fa311 100644 --- a/src/copy.c +++ b/src/copy.c @@ -798,15 +798,9 @@ copy_reg (char const *src_name, char const *dst_name, if (last_write_made_hole) { - if (HAVE_FTRUNCATE - ? /* ftruncate sets the file size, - so there is no need for a write. */ - ftruncate (dest_desc, n_read_total) < 0 - : /* Seek backwards one character and write a null. */ - (lseek (dest_desc, (off_t) -1, SEEK_CUR) < 0L - || full_write (dest_desc, "", 1) != 1)) + if (ftruncate (dest_desc, n_read_total) < 0) { - error (0, errno, _("writing %s"), quote (dst_name)); + error (0, errno, _("truncating %s"), quote (dst_name)); return_val = false; goto close_src_and_dst_desc; } diff --git a/src/truncate.c b/src/truncate.c index 70573cc2f..ece52ee76 100644 --- a/src/truncate.c +++ b/src/truncate.c @@ -18,12 +18,7 @@ This is backwards compatible with the FreeBSD utility, but is more flexible wrt the size specifications and the use of long options, - to better fit the "GNU" environment. - - Note if !defined(HAVE_FTRUNCATE) then the --skip-ftruncate configure flag - was specified or we're in a mingw environment. In these cases gnulib - emulation will be used and GNULIB_FTRUNCATE is defined. Note if emulation - can't even be provided ftruncate() will return EIO. */ + to better fit the "GNU" environment. */ #include /* sets _FILE_OFFSET_BITS=64 etc. */ #include -- cgit v1.2.3-54-g00ecf