Hash :
d0450ae9
Author :
Date :
2024-01-17T21:53:15
Improve naming of local variables. * gnulib-tool, posix-modules, build-aux/relocatable.sh.in, build-aux/reloc-ldflags, build-aux/install-reloc, tests/init.sh, m4/argz.m4: Rename save_IFS to saved_IFS. * m4/*.m4: Rename save_LIBS to saved_LIBS. * m4/00gnulib.m4, m4/gnulib-common.m4, m4/warn-on-use.m4, m4/wchar_h.m4: Rename save_ac_compile to saved_ac_compile. * m4/00gnulib.m4: Rename ac_save_ac_compile to ac_saved_ac_compile. * m4/gnulib-common.m4: Rename save_ac_compile_for_check_decl to saved_ac_compile_for_check_decl. * m4/assert_h.m4, m4/manywarnings.m4, m4/stdalign.m4, m4/visibility.m4: Rename gl_save_CFLAGS to gl_saved_CFLAGS. * m4/dirfd.m4: Rename dirfd_save_CFLAGS to gl_saved_CFLAGS. * m4/include_next.m4, m4/pread.m4, m4/pwrite.m4, m4/termcap.m4, m4/terminfo.m4: Rename gl_save_CPPFLAGS to gl_saved_CPPFLAGS. * m4/lib-link.m4: Rename ac_save_CPPFLAGS to acl_save_CPPFLAGS. * m4/iconv.m4, m4/readline.m4: Rename am_save_CPPFLAGS to gl_saved_CPPFLAGS. * m4/gettext.m4: Rename gt_save_CPPFLAGS to gt_saved_CPPFLAGS. * m4/ansi-c++.m4: Rename gl_save_CXX to gl_saved_CXX. * m4/manywarnings-c++.m4: Rename gl_save_CXXFLAGS to gl_saved_CXXFLAGS. * m4/lib-link.m4: Rename acl_save_ifs to acl_saved_IFS. * m4/lib-prefix.m4: Rename acl_save_IFS to acl_saved_IFS. * m4/progtest.m4: Rename ac_save_IFS to gt_saved_IFS. * m4/lib-link.m4: Rename save_libdir to saved_libdir, acl_save_libdir to acl_saved_libdir. * m4/ld-version-script.m4: Rename save_LDFLAGS to saved_LDFLAGS. * m4/acl.m4, m4/getgroups.m4: Rename ac_save_LIBS to gl_saved_LIBS. * m4/lib-link.m4: Rename ac_save_LIBS to acl_saved_LIBS. * m4/getdomainname.m4, m4/gethostname.m4, m4/getloadavg.m4, m4/hostent.m4, m4/inet_ntop.m4, m4/inet_pton.m4, m4/pthread_mutex_timedlock.m4, m4/pthread_sigmask.m4, m4/pthread-spin.m4, m4/readutmp.m4, m4/selinux-selinux-h.m4, m4/servent.m4, m4/socketlib.m4, m4/termcap.m4, m4/terminfo.m4, m4/thread.m4: Rename gl_save_LIBS to gl_saved_LIBS. * m4/getaddrinfo.m4, m4/iconv.m4, m4/readline.m4: Rename am_save_LIBS to gl_saved_LIBS. * m4/gettext.m4, m4/intlmacosx.m4: Rename gt_save_LIBS to gt_saved_LIBS. * m4/libunistring.m4: Rename glus_save_LIBS to glus_saved_LIBS. * m4/nanosleep.m4: Rename nanosleep_save_libs to gl_saved_LIBS. * m4/lib-prefix.m4: Rename acl_save_prefix to acl_saved_prefix, acl_save_exec_prefix to acl_saved_exec_prefix. * m4/configmake.m4: Rename gl_save_<variable> to gl_saved_<variable>. * m4/terminfo.m4: Likewise. * m4/gettext.m4: Rename gt_save_<variable> to gt_saved_<variable>. * m4/javaexec.m4: Rename save_CLASSPATH to gt_saved_CLASSPATH. * m4/warnings.m4: Rename gl_save_compiler_FLAGS to gl_saved_compiler_FLAGS. * lib/pread.c, lib/pwrite.c, lib/read-file.c, lib/tempname.c: Rename save_errno to saved_errno. * lib/read-file.c: Rename save_alloc to saved_alloc. * lib/strptime.c: Rename save_wday to saved_wday, save_mday to saved_mday, save_mon to saved_mon.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
/* replacement pread function
Copyright (C) 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <unistd.h>
#include <errno.h>
#define __libc_lseek(f,o,w) lseek (f, o, w)
#define __set_errno(Val) errno = (Val)
#define __libc_read(f,b,n) read (f, b, n)
/* pread substitute for systems that the function, such as mingw32 and BeOS. */
/* The following is identical to the function from glibc's
sysdeps/posix/pread.c */
/* Note: This implementation of pread is not multithread-safe. */
ssize_t
pread (int fd, void *buf, size_t nbyte, off_t offset)
{
/* Since we must not change the file pointer preserve the value so that
we can restore it later. */
int saved_errno;
ssize_t result;
off_t old_offset = __libc_lseek (fd, 0, SEEK_CUR);
if (old_offset == (off_t) -1)
return -1;
/* Set to wanted position. */
if (__libc_lseek (fd, offset, SEEK_SET) == (off_t) -1)
return -1;
/* Write out the data. */
result = __libc_read (fd, buf, nbyte);
/* Now we have to restore the position. If this fails we have to
return this as an error. But if the writing also failed we
return this error. */
saved_errno = errno;
if (__libc_lseek (fd, old_offset, SEEK_SET) == (off_t) -1)
{
if (result == -1)
__set_errno (saved_errno);
return -1;
}
__set_errno (saved_errno);
return result;
}