--- embedaddon/libiconv/srclib/read.c 2012/05/29 09:29:42 1.1.1.1 +++ embedaddon/libiconv/srclib/read.c 2021/03/17 13:38:46 1.1.1.2 @@ -1,5 +1,5 @@ /* POSIX compatible read() function. - Copyright (C) 2008-2011 Free Software Foundation, Inc. + Copyright (C) 2008-2019 Free Software Foundation, Inc. Written by Bruno Haible , 2011. This program is free software: you can redistribute it and/or modify @@ -13,30 +13,61 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + along with this program. If not, see . */ #include /* Specification. */ #include -/* Replace this function only if module 'nonblocking' is requested. */ -#if GNULIB_NONBLOCKING +#if defined _WIN32 && ! defined __CYGWIN__ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# include +# include -# include +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +# endif +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else # include +# endif -# define WIN32_LEAN_AND_MEAN /* avoid including junk */ -# include +# undef read +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static ssize_t +read_nothrow (int fd, void *buf, size_t count) +{ + ssize_t result; + + TRY_MSVC_INVAL + { + result = read (fd, buf, count); + } + CATCH_MSVC_INVAL + { + result = -1; + errno = EBADF; + } + DONE_MSVC_INVAL; + + return result; +} +# else +# define read_nothrow read +# endif + ssize_t rpl_read (int fd, void *buf, size_t count) -#undef read { - ssize_t ret = read (fd, buf, count); + ssize_t ret = read_nothrow (fd, buf, count); +# if GNULIB_NONBLOCKING if (ret < 0 && GetLastError () == ERROR_NO_DATA) { @@ -52,8 +83,9 @@ rpl_read (int fd, void *buf, size_t count) errno = EAGAIN; } } +# endif + return ret; } -# endif #endif