summaryrefslogtreecommitdiff
path: root/gl
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-11-20 09:23:24 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-11-20 09:33:59 +0100
commit5653b4db4ee6ae5a8600ecacaedb577080dac0d4 (patch)
tree64e42e18241e3bbe893ec1d234210b59437b9765 /gl
parent7150a903a274492f88b4580d26c667ddc40fee67 (diff)
downloadgnutls-5653b4db4ee6ae5a8600ecacaedb577080dac0d4.tar.gz
use gnulib to detect iconv.
Diffstat (limited to 'gl')
-rw-r--r--gl/Makefile.am13
-rw-r--r--gl/dup2.c (renamed from gl/tests/dup2.c)0
-rw-r--r--gl/errno.in.h5
-rw-r--r--gl/m4/errno_h.m45
-rw-r--r--gl/m4/gnulib-cache.m43
-rw-r--r--gl/m4/gnulib-comp.m420
-rw-r--r--gl/m4/select.m440
-rw-r--r--gl/m4/stdlib_h.m41
-rw-r--r--gl/select.c19
-rw-r--r--gl/stdlib.in.h13
-rw-r--r--gl/strerror-override.c5
-rw-r--r--gl/strerror-override.h3
-rw-r--r--gl/tests/Makefile.am19
-rw-r--r--gl/tests/fcntl.in.h14
-rw-r--r--gl/tests/test-fcntl-h.c17
-rw-r--r--gl/tests/test-iconv.c148
-rw-r--r--gl/tests/test-select.h25
17 files changed, 322 insertions, 28 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am
index a277b6f692..1e232c3205 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alloca alphasort argp base64 bind byteswap c-ctype close connect error extensions func gendocs getaddrinfo getpass getsubopt gettext gettime hash-pjw-bare havelib inet_ntop inet_pton lib-msvc-compat lib-symbol-versions listen maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html progname read-file recv recvfrom scandir select send sendto servent setsockopt shutdown snprintf socket sockets socklen stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r timer-time timespec u64 unistd valgrind-tests vasprintf version-etc version-etc-fsf vfprintf-posix vprintf-posix vsnprintf warnings
+# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alloca alphasort argp base64 bind byteswap c-ctype close connect error extensions func gendocs getaddrinfo getpass getsubopt gettext gettime hash-pjw-bare havelib iconv inet_ntop inet_pton lib-msvc-compat lib-symbol-versions listen maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html progname read-file recv recvfrom scandir select send sendto servent setsockopt shutdown snprintf socket sockets socklen stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r timer-time timespec u64 unistd valgrind-tests vasprintf version-etc version-etc-fsf vfprintf-posix vprintf-posix vsnprintf warnings
AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
@@ -59,6 +59,7 @@ libgnu_la_LDFLAGS += $(LIBSOCKET)
libgnu_la_LDFLAGS += $(LIB_CLOCK_GETTIME)
libgnu_la_LDFLAGS += $(LIB_SELECT)
libgnu_la_LDFLAGS += $(LIB_TIMER_TIME)
+libgnu_la_LDFLAGS += $(LTLIBICONV)
libgnu_la_LDFLAGS += $(LTLIBINTL)
libgnu_la_LDFLAGS += $(LTLIBTHREAD)
libgnu_la_LDFLAGS += $(SERVENT_LIB)
@@ -294,6 +295,15 @@ EXTRA_DIST += dosname.h
## end gnulib module dosname
+## begin gnulib module dup2
+
+
+EXTRA_DIST += dup2.c
+
+EXTRA_libgnu_la_SOURCES += dup2.c
+
+## end gnulib module dup2
+
## begin gnulib module errno
BUILT_SOURCES += $(ERRNO_H)
@@ -1784,6 +1794,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
-e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
-e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
+ -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
-e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
-e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
-e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
diff --git a/gl/tests/dup2.c b/gl/dup2.c
index f6d0f1c73c..f6d0f1c73c 100644
--- a/gl/tests/dup2.c
+++ b/gl/dup2.c
diff --git a/gl/errno.in.h b/gl/errno.in.h
index 5e5af9276e..f9612c3aff 100644
--- a/gl/errno.in.h
+++ b/gl/errno.in.h
@@ -270,5 +270,10 @@
# define GNULIB_defined_ENOTRECOVERABLE 1
# endif
+# ifndef EILSEQ
+# define EILSEQ 2015
+# define GNULIB_defined_EILSEQ 1
+# endif
+
#endif /* _@GUARD_PREFIX@_ERRNO_H */
#endif /* _@GUARD_PREFIX@_ERRNO_H */
diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4
index 1e76ba270a..4e33ba853a 100644
--- a/gl/m4/errno_h.m4
+++ b/gl/m4/errno_h.m4
@@ -1,4 +1,4 @@
-# errno_h.m4 serial 11
+# errno_h.m4 serial 12
dnl Copyright (C) 2004, 2006, 2008-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -58,6 +58,9 @@ booboo
#if !defined ENOTRECOVERABLE
booboo
#endif
+#if !defined EILSEQ
+booboo
+#endif
],
[gl_cv_header_errno_h_complete=no],
[gl_cv_header_errno_h_complete=yes])
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index 04f3d46735..0a3d49ba9f 100644
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
@@ -27,7 +27,7 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alloca alphasort argp base64 bind byteswap c-ctype close connect error extensions func gendocs getaddrinfo getpass getsubopt gettext gettime hash-pjw-bare havelib inet_ntop inet_pton lib-msvc-compat lib-symbol-versions listen maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html progname read-file recv recvfrom scandir select send sendto servent setsockopt shutdown snprintf socket sockets socklen stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r timer-time timespec u64 unistd valgrind-tests vasprintf version-etc version-etc-fsf vfprintf-posix vprintf-posix vsnprintf warnings
+# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alloca alphasort argp base64 bind byteswap c-ctype close connect error extensions func gendocs getaddrinfo getpass getsubopt gettext gettime hash-pjw-bare havelib iconv inet_ntop inet_pton lib-msvc-compat lib-symbol-versions listen maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html progname read-file recv recvfrom scandir select send sendto servent setsockopt shutdown snprintf socket sockets socklen stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r timer-time timespec u64 unistd valgrind-tests vasprintf version-etc version-etc-fsf vfprintf-posix vprintf-posix vsnprintf warnings
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([gl/override])
@@ -53,6 +53,7 @@ gl_MODULES([
gettime
hash-pjw-bare
havelib
+ iconv
inet_ntop
inet_pton
lib-msvc-compat
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 9b6156211b..afef0fb8b7 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -143,6 +143,8 @@ AC_DEFUN([gl_EARLY],
# Code from module hash-pjw-bare:
# Code from module havelib:
# Code from module hostent:
+ # Code from module iconv:
+ # Code from module iconv-tests:
# Code from module ignore-value:
# Code from module ignore-value-tests:
# Code from module include_next:
@@ -415,6 +417,12 @@ AC_SUBST([LTALLOCA])
gl_DIRENT_H
gl_DIRNAME_LGPL
gl_DOUBLE_SLASH_ROOT
+ gl_FUNC_DUP2
+ if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then
+ AC_LIBOBJ([dup2])
+ gl_PREREQ_DUP2
+ fi
+ gl_UNISTD_MODULE_INDICATOR([dup2])
gl_HEADER_ERRNO_H
gl_ERROR
if test $ac_cv_lib_error_at_line = no; then
@@ -552,6 +560,9 @@ AC_SUBST([LTALLOCA])
[AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [],
[GNUmakefile=$GNUmakefile])])
gl_HOSTENT
+ AM_ICONV
+ m4_ifdef([gl_ICONV_MODULE_INDICATOR],
+ [gl_ICONV_MODULE_INDICATOR([iconv])])
gl_FUNC_INET_NTOP
if test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1; then
AC_LIBOBJ([inet_ntop])
@@ -891,12 +902,6 @@ changequote([, ])dnl
AC_SUBST([gltests_WITNESS])
gl_module_indicator_condition=$gltests_WITNESS
m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition])
- gl_FUNC_DUP2
- if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then
- AC_LIBOBJ([dup2])
- gl_PREREQ_DUP2
- fi
- gl_UNISTD_MODULE_INDICATOR([dup2])
gl_ENVIRON
gl_UNISTD_MODULE_INDICATOR([environ])
gl_FCNTL_H
@@ -1160,6 +1165,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/dirname-lgpl.c
lib/dirname.h
lib/dosname.h
+ lib/dup2.c
lib/errno.in.h
lib/error.c
lib/error.h
@@ -1562,6 +1568,7 @@ AC_DEFUN([gl_FILE_LIST], [
tests/test-getopt_long.h
tests/test-getpeername.c
tests/test-gettimeofday.c
+ tests/test-iconv.c
tests/test-ignore-value.c
tests/test-inet_ntop.c
tests/test-inet_pton.c
@@ -1662,7 +1669,6 @@ AC_DEFUN([gl_FILE_LIST], [
tests/zerosize-ptr.h
tests=lib/binary-io.c
tests=lib/binary-io.h
- tests=lib/dup2.c
tests=lib/fcntl.in.h
tests=lib/fdopen.c
tests=lib/ftruncate.c
diff --git a/gl/m4/select.m4 b/gl/m4/select.m4
index 037b3d3cfc..d135a39db9 100644
--- a/gl/m4/select.m4
+++ b/gl/m4/select.m4
@@ -1,4 +1,4 @@
-# select.m4 serial 6
+# select.m4 serial 7
dnl Copyright (C) 2009-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -46,6 +46,44 @@ changequote([,])dnl
*yes) ;;
*) REPLACE_SELECT=1 ;;
esac
+
+ dnl On FreeBSD 8.2, select() doesn't always reject bad fds.
+ AC_CACHE_CHECK([whether select detects invalid fds],
+ [gl_cv_func_select_detects_ebadf],
+ [
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/types.h>
+#include <sys/time.h>
+#if HAVE_SYS_SELECT_H
+# include <sys/select.h>
+#endif
+#include <unistd.h>
+#include <errno.h>
+]],[[
+ fd_set set;
+ dup2(0, 16);
+ FD_ZERO(&set);
+ FD_SET(16, &set);
+ close(16);
+ struct timeval timeout;
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 5;
+ return select (17, &set, NULL, NULL, &timeout) != -1 || errno != EBADF;
+]])], [gl_cv_func_select_detects_ebadf=yes],
+ [gl_cv_func_select_detects_ebadf=no],
+ [
+ case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_select_detects_ebadf="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_select_detects_ebadf="guessing no" ;;
+ esac
+ ])
+ ])
+ case $gl_cv_func_select_detects_ebadf in
+ *yes) ;;
+ *) REPLACE_SELECT=1 ;;
+ esac
fi
dnl Determine the needed libraries.
diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4
index ab43728ace..9c69f2e4d1 100644
--- a/gl/m4/stdlib_h.m4
+++ b/gl/m4/stdlib_h.m4
@@ -102,6 +102,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC])
REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC])
REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
+ REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME])
REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R])
REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R])
diff --git a/gl/select.c b/gl/select.c
index d6acb5c371..af043c5e4f 100644
--- a/gl/select.c
+++ b/gl/select.c
@@ -507,6 +507,8 @@ restart:
#include <sys/select.h>
#include <stddef.h> /* NULL */
+#include <errno.h>
+#include <unistd.h>
#undef select
@@ -514,6 +516,23 @@ int
rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
struct timeval *timeout)
{
+ int i;
+
+ /* FreeBSD 8.2 has a bug: it does not always detect invalid fds. */
+ if (nfds < 0 || nfds > FD_SETSIZE)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ for (i = 0; i < nfds; i++)
+ {
+ if (((rfds && FD_ISSET (i, rfds))
+ || (wfds && FD_ISSET (i, wfds))
+ || (xfds && FD_ISSET (i, xfds)))
+ && dup2 (i, i) != i)
+ return -1;
+ }
+
/* Interix 3.5 has a bug: it does not support nfds == 0. */
if (nfds == 0)
{
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index 1d67ec64c6..65558402bf 100644
--- a/gl/stdlib.in.h
+++ b/gl/stdlib.in.h
@@ -457,10 +457,19 @@ _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
#if @GNULIB_PTSNAME@
/* Return the pathname of the pseudo-terminal slave associated with
the master FD is open on, or NULL on errors. */
-# if !@HAVE_PTSNAME@
+# if @REPLACE_PTSNAME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ptsname
+# define ptsname rpl_ptsname
+# endif
+_GL_FUNCDECL_RPL (ptsname, char *, (int fd));
+_GL_CXXALIAS_RPL (ptsname, char *, (int fd));
+# else
+# if !@HAVE_PTSNAME@
_GL_FUNCDECL_SYS (ptsname, char *, (int fd));
-# endif
+# endif
_GL_CXXALIAS_SYS (ptsname, char *, (int fd));
+# endif
_GL_CXXALIASWARN (ptsname);
#elif defined GNULIB_POSIXCHECK
# undef ptsname
diff --git a/gl/strerror-override.c b/gl/strerror-override.c
index 9f55cfa9ac..f7cac65f75 100644
--- a/gl/strerror-override.c
+++ b/gl/strerror-override.c
@@ -291,6 +291,11 @@ strerror_override (int errnum)
return "State not recoverable";
#endif
+#if GNULIB_defined_EILSEQ
+ case EILSEQ:
+ return "Invalid or incomplete multibyte or wide character";
+#endif
+
default:
return NULL;
}
diff --git a/gl/strerror-override.h b/gl/strerror-override.h
index fe1fb2c229..6468681366 100644
--- a/gl/strerror-override.h
+++ b/gl/strerror-override.h
@@ -46,7 +46,8 @@
|| GNULIB_defined_EDQUOT \
|| GNULIB_defined_ECANCELED \
|| GNULIB_defined_EOWNERDEAD \
- || GNULIB_defined_ENOTRECOVERABLE
+ || GNULIB_defined_ENOTRECOVERABLE \
+ || GNULIB_defined_EILSEQ
extern const char *strerror_override (int errnum);
# else
# define strerror_override(ignored) NULL
diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am
index 5a74e77a73..70cc6d6f32 100644
--- a/gl/tests/Makefile.am
+++ b/gl/tests/Makefile.am
@@ -167,15 +167,6 @@ EXTRA_DIST += test-dirent.c
## end gnulib module dirent-tests
-## begin gnulib module dup2
-
-
-EXTRA_DIST += dup2.c
-
-EXTRA_libtests_a_SOURCES += dup2.c
-
-## end gnulib module dup2
-
## begin gnulib module dup2-tests
TESTS += test-dup2
@@ -477,6 +468,16 @@ EXTRA_DIST += signature.h test-gettimeofday.c
## end gnulib module gettimeofday-tests
+## begin gnulib module iconv-tests
+
+TESTS += test-iconv
+check_PROGRAMS += test-iconv
+test_iconv_LDADD = $(LDADD) @LIBICONV@
+
+EXTRA_DIST += test-iconv.c signature.h macros.h
+
+## end gnulib module iconv-tests
+
## begin gnulib module ignore-value
diff --git a/gl/tests/fcntl.in.h b/gl/tests/fcntl.in.h
index 76e12f78a6..604c31b798 100644
--- a/gl/tests/fcntl.in.h
+++ b/gl/tests/fcntl.in.h
@@ -216,6 +216,10 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
# define O_EXEC O_RDONLY /* This is often close enough in older systems. */
#endif
+#ifndef O_IGNORE_CTTY
+# define O_IGNORE_CTTY 0
+#endif
+
#ifndef O_NDELAY
# define O_NDELAY 0
#endif
@@ -249,10 +253,18 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
# define O_NOFOLLOW 0
#endif
+#ifndef O_NOLINK
+# define O_NOLINK 0
+#endif
+
#ifndef O_NOLINKS
# define O_NOLINKS 0
#endif
+#ifndef O_NOTRANS
+# define O_NOTRANS 0
+#endif
+
#ifndef O_RSYNC
# define O_RSYNC 0
#endif
@@ -269,7 +281,7 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
# define O_TTY_INIT 0
#endif
-#if O_ACCMODE != (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
+#if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
# undef O_ACCMODE
# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
#endif
diff --git a/gl/tests/test-fcntl-h.c b/gl/tests/test-fcntl-h.c
index 00c5468dff..a6c962106e 100644
--- a/gl/tests/test-fcntl-h.c
+++ b/gl/tests/test-fcntl-h.c
@@ -21,9 +21,9 @@
#include <fcntl.h>
/* Check that the various O_* macros are defined. */
-int o = O_DIRECT | O_DIRECTORY | O_DSYNC | O_NDELAY | O_NOATIME | O_NONBLOCK
- | O_NOCTTY | O_NOFOLLOW | O_NOLINKS | O_RSYNC | O_SYNC | O_TTY_INIT
- | O_BINARY | O_TEXT;
+int o = (O_DIRECT | O_DIRECTORY | O_DSYNC | O_IGNORE_CTTY | O_NDELAY | O_NOATIME
+ | O_NONBLOCK | O_NOCTTY | O_NOFOLLOW | O_NOLINK | O_NOLINKS | O_NOTRANS
+ | O_RSYNC | O_SYNC | O_TTY_INIT | O_BINARY | O_TEXT);
/* Check that the various SEEK_* macros are defined. */
int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET };
@@ -61,7 +61,7 @@ main (void)
#if O_SEARCH && O_EXEC != O_SEARCH && O_SEARCH != O_RDONLY
case O_SEARCH:
#endif
- i = O_ACCMODE == (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH);
+ i = ! (~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH));
break;
/* Everyone should have these */
@@ -84,6 +84,9 @@ main (void)
#if O_DSYNC
case O_DSYNC:
#endif
+#if O_IGNORE_CTTY
+ case O_IGNORE_CTTY:
+#endif
#if O_NOATIME
case O_NOATIME:
#endif
@@ -96,9 +99,15 @@ main (void)
#if O_NOFOLLOW
case O_NOFOLLOW:
#endif
+#if O_NOLINK
+ case O_NOLINK:
+#endif
#if O_NOLINKS
case O_NOLINKS:
#endif
+#if O_NOTRANS
+ case O_NOTRANS:
+#endif
#if O_RSYNC && O_RSYNC != O_DSYNC
case O_RSYNC:
#endif
diff --git a/gl/tests/test-iconv.c b/gl/tests/test-iconv.c
new file mode 100644
index 0000000000..333af2a949
--- /dev/null
+++ b/gl/tests/test-iconv.c
@@ -0,0 +1,148 @@
+/* Test of character set conversion.
+ Copyright (C) 2007-2012 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 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 <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#if HAVE_ICONV
+# include <iconv.h>
+
+# ifndef ICONV_CONST
+# define ICONV_CONST /* empty */
+# endif
+
+#include "signature.h"
+SIGNATURE_CHECK (iconv, size_t, (iconv_t, ICONV_CONST char **, size_t *,
+ char **, size_t *));
+SIGNATURE_CHECK (iconv_close, int, (iconv_t x));
+SIGNATURE_CHECK (iconv_open, iconv_t, (char const *, char const *));
+
+#endif
+
+#include <errno.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+#if HAVE_ICONV
+ /* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
+ and UTF-8. */
+ iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
+ iconv_t cd_utf8_to_88591 = iconv_open ("ISO-8859-1", "UTF-8");
+
+ ASSERT (cd_88591_to_utf8 != (iconv_t)(-1));
+ ASSERT (cd_utf8_to_88591 != (iconv_t)(-1));
+
+ /* Test conversion from ISO-8859-1 to UTF-8 with no errors. */
+ {
+ static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
+ static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
+ char buf[50];
+ const char *inptr = input;
+ size_t inbytesleft = strlen (input);
+ char *outptr = buf;
+ size_t outbytesleft = sizeof (buf);
+ size_t res = iconv (cd_88591_to_utf8,
+ (ICONV_CONST char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ ASSERT (res == 0 && inbytesleft == 0);
+ ASSERT (outptr == buf + strlen (expected));
+ ASSERT (memcmp (buf, expected, strlen (expected)) == 0);
+ }
+
+ /* Test conversion from ISO-8859-1 to UTF-8 with E2BIG. */
+ {
+ static const char input[] = "\304";
+ static char buf[2] = { (char)0xDE, (char)0xAD };
+ const char *inptr = input;
+ size_t inbytesleft = 1;
+ char *outptr = buf;
+ size_t outbytesleft = 1;
+ size_t res = iconv (cd_88591_to_utf8,
+ (ICONV_CONST char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ ASSERT (res == (size_t)(-1) && errno == E2BIG);
+ ASSERT (inbytesleft == 1);
+ ASSERT (outbytesleft == 1);
+ ASSERT ((unsigned char) buf[1] == 0xAD);
+ ASSERT ((unsigned char) buf[0] == 0xDE);
+ }
+
+ /* Test conversion from UTF-8 to ISO-8859-1 with no errors. */
+ {
+ static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
+ static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
+ char buf[50];
+ const char *inptr = input;
+ size_t inbytesleft = strlen (input);
+ char *outptr = buf;
+ size_t outbytesleft = sizeof (buf);
+ size_t res = iconv (cd_utf8_to_88591,
+ (ICONV_CONST char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ ASSERT (res == 0 && inbytesleft == 0);
+ ASSERT (outptr == buf + strlen (expected));
+ ASSERT (memcmp (buf, expected, strlen (expected)) == 0);
+ }
+
+ /* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */
+ {
+ static const char input[] = "\342\202\254"; /* EURO SIGN */
+ char buf[10];
+ const char *inptr = input;
+ size_t inbytesleft = strlen (input);
+ char *outptr = buf;
+ size_t outbytesleft = sizeof (buf);
+ size_t res = iconv (cd_utf8_to_88591,
+ (ICONV_CONST char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ if (res == (size_t)(-1))
+ {
+ ASSERT (errno == EILSEQ);
+ ASSERT (inbytesleft == strlen (input) && outptr == buf);
+ }
+ else
+ {
+ ASSERT (res == 1);
+ ASSERT (inbytesleft == 0);
+ }
+ }
+
+ /* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */
+ {
+ static const char input[] = "\342";
+ char buf[10];
+ const char *inptr = input;
+ size_t inbytesleft = 1;
+ char *outptr = buf;
+ size_t outbytesleft = sizeof (buf);
+ size_t res = iconv (cd_utf8_to_88591,
+ (ICONV_CONST char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ ASSERT (res == (size_t)(-1) && errno == EINVAL);
+ ASSERT (inbytesleft == 1 && outptr == buf);
+ }
+
+ iconv_close (cd_88591_to_utf8);
+ iconv_close (cd_utf8_to_88591);
+#endif
+
+ return 0;
+}
diff --git a/gl/tests/test-select.h b/gl/tests/test-select.h
index af0e38cf09..e9cb7d04f4 100644
--- a/gl/tests/test-select.h
+++ b/gl/tests/test-select.h
@@ -227,6 +227,29 @@ test_tty (select_fn my_select)
#endif
+static int
+do_select_bad_nfd_nowait (int nfd, select_fn my_select)
+{
+ struct timeval tv0;
+ tv0.tv_sec = 0;
+ tv0.tv_usec = 0;
+ errno = 0;
+ return my_select (nfd, NULL, NULL, NULL, &tv0);
+}
+
+static void
+test_bad_nfd (select_fn my_select)
+{
+ if (do_select_bad_nfd_nowait (-1, my_select) != -1 || errno != EINVAL)
+ failed ("invalid errno after negative nfds");
+ /* Can't test FD_SETSIZE + 1 for EINVAL, since some systems allow
+ dynamically larger set size by redefining FD_SETSIZE anywhere up
+ to the actual maximum fd. */
+ /* if (do_select_bad_nfd_nowait (FD_SETSIZE + 1, my_select) != -1 */
+ /* || errno != EINVAL) */
+ /* failed ("invalid errno after bogus nfds"); */
+}
+
/* Test select(2) on invalid file descriptors. */
static int
@@ -243,6 +266,7 @@ do_select_bad_fd (int fd, int ev, struct timeval *timeout, select_fn my_select)
FD_SET (fd, &wfds);
if (ev & SEL_EXC)
FD_SET (fd, &xfds);
+ errno = 0;
return my_select (fd + 1, &rfds, &wfds, &xfds, timeout);
/* In this case, when fd is invalid, on some platforms, the bit for fd
is left alone in the fd_set, whereas on other platforms it is cleared.
@@ -426,6 +450,7 @@ test_function (select_fn my_select)
test (test_tty, "TTY", my_select);
#endif
+ result += test (test_bad_nfd, my_select, "Invalid nfd test");
result += test (test_bad_fd, my_select, "Invalid fd test");
result += test (test_connect_first, my_select, "Unconnected socket test");
result += test (test_socket_pair, my_select, "Connected sockets test");