From: Bruno Haible Date: Tue, 18 Feb 2003 13:25:19 +0000 (+0000) Subject: Simplify code. X-Git-Tag: v0.12~212 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=0ea98c67616575b43c5c54d9a1e23a218a98ac27;p=thirdparty%2Fgettext.git Simplify code. --- diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index e509d4198..a8085f3e7 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,3 +1,8 @@ +2003-02-18 Bruno Haible + + * copy-file.c: Include safe-read.h. + (copy_file): Simplify code by using safe_read() instead of read(). + 2003-02-12 Bruno Haible * Makefile.am (EXTRA_DIST): Add ChangeLog.0. diff --git a/gettext-tools/lib/copy-file.c b/gettext-tools/lib/copy-file.c index 1d924645b..84b07ac86 100644 --- a/gettext-tools/lib/copy-file.c +++ b/gettext-tools/lib/copy-file.c @@ -1,5 +1,5 @@ /* Copying of files. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -41,6 +41,7 @@ #endif #include "error.h" +#include "safe-read.h" #include "full-write.h" #include "binary-io.h" #include "exit.h" @@ -73,15 +74,9 @@ copy_file (const char *src_filename, const char *dest_filename) /* Copy the file contents. */ for (;;) { - ssize_t n_read = read (src_fd, buf, buf_size); - if (n_read < 0) - { -#ifdef EINTR - if (errno == EINTR) - continue; -#endif - error (EXIT_FAILURE, errno, _("error reading \"%s\""), src_filename); - } + size_t n_read = safe_read (src_fd, buf, buf_size); + if (n_read == SAFE_READ_ERROR) + error (EXIT_FAILURE, errno, _("error reading \"%s\""), src_filename); if (n_read == 0) break;