diff options
author | Simon Josefsson <simon@josefsson.org> | 2007-01-31 04:48:42 +0000 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2007-01-31 04:48:42 +0000 |
commit | e7fb1c2a2085133739a9e661866f97da146d8137 (patch) | |
tree | 593e71e3da1e85175a201b8e682c3a959492994d | |
parent | 554e4119202f749b36c72b79b4969a1794867bcf (diff) | |
download | gnutls-e7fb1c2a2085133739a9e661866f97da146d8137.tar.gz |
Update.
-rw-r--r-- | gl/getaddrinfo.c | 5 | ||||
-rw-r--r-- | gl/gnulib.mk | 40 | ||||
-rw-r--r-- | gl/m4/absolute-header.m4 | 44 | ||||
-rw-r--r-- | gl/m4/extensions.m4 | 58 | ||||
-rw-r--r-- | gl/m4/gnulib-common.m4 | 11 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 9 | ||||
-rw-r--r-- | gl/m4/strdup.m4 | 11 | ||||
-rw-r--r-- | gl/m4/string_h.m4 | 46 | ||||
-rw-r--r-- | gl/socket_.h | 10 | ||||
-rw-r--r-- | gl/strdup.c | 8 | ||||
-rw-r--r-- | gl/string_.h | 182 | ||||
-rw-r--r-- | lgl/Makefile.am | 64 | ||||
-rw-r--r-- | lgl/m4/extensions.m4 | 58 | ||||
-rw-r--r-- | lgl/m4/gnulib-common.m4 | 11 | ||||
-rw-r--r-- | lgl/m4/gnulib-comp.m4 | 12 | ||||
-rw-r--r-- | lgl/m4/memmem.m4 | 8 | ||||
-rw-r--r-- | lgl/m4/stdint.m4 | 80 | ||||
-rw-r--r-- | lgl/m4/string_h.m4 | 46 | ||||
-rw-r--r-- | lgl/m4/unistd_h.m4 | 19 | ||||
-rw-r--r-- | lgl/m4/wchar.m4 | 29 | ||||
-rw-r--r-- | lgl/printf-args.c | 12 | ||||
-rw-r--r-- | lgl/printf-args.h | 26 | ||||
-rw-r--r-- | lgl/printf-parse.c | 20 | ||||
-rw-r--r-- | lgl/socket_.h | 10 | ||||
-rw-r--r-- | lgl/stdint_.h | 8 | ||||
-rw-r--r-- | lgl/string_.h | 182 | ||||
-rw-r--r-- | lgl/vasnprintf.c | 36 | ||||
-rw-r--r-- | lgl/wchar_.h | 42 |
28 files changed, 963 insertions, 124 deletions
diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c index f523f7658e..add56ba1bd 100644 --- a/gl/getaddrinfo.c +++ b/gl/getaddrinfo.c @@ -1,5 +1,5 @@ /* Get address information (partial implementation). - Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006 Free Software + Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Contributed by Simon Josefsson <simon@josefsson.org>. @@ -28,7 +28,7 @@ /* Get calloc. */ #include <stdlib.h> -/* Get memcpy. */ +/* Get memcpy, strdup. */ #include <string.h> #include <stdbool.h> @@ -39,7 +39,6 @@ #include "inet_ntop.h" #include "snprintf.h" -#include "strdup.h" /* BeOS has AF_INET, but not PF_INET. */ #ifndef PF_INET diff --git a/gl/gnulib.mk b/gl/gnulib.mk index 8cadb62120..85c3104bdc 100644 --- a/gl/gnulib.mk +++ b/gl/gnulib.mk @@ -148,12 +148,48 @@ EXTRA_DIST += stdbool_.h ## begin gnulib module strdup -EXTRA_DIST += strdup.c strdup.h +EXTRA_DIST += strdup.c EXTRA_libgnu_la_SOURCES += strdup.c ## end gnulib module strdup +## begin gnulib module string + +BUILT_SOURCES += string.h + +# We need the following in order to create <string.h> when the system +# doesn't have one that works with the given compiler. +string.h: string_.h + rm -f $@-t $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's|@''ABSOLUTE_STRING_H''@|$(ABSOLUTE_STRING_H)|g' \ + -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ + -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ + -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ + -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \ + -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ + -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \ + -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ + -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \ + -e 's|@''HAVE_STRNDUP''@|$(HAVE_STRNDUP)|g' \ + -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \ + -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \ + -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \ + -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \ + -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ + -e 's|@''REPLACE_STRCASECMP''@|$(REPLACE_STRCASECMP)|g' \ + -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ + -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ + < $(srcdir)/string_.h; \ + } > $@-t + mv $@-t $@ +MOSTLYCLEANFILES += string.h string.h-t + +EXTRA_DIST += string_.h + +## end gnulib module string + ## begin gnulib module sys_socket BUILT_SOURCES += $(SYS_SOCKET_H) @@ -161,7 +197,7 @@ BUILT_SOURCES += $(SYS_SOCKET_H) # We need the following in order to create <sys/socket.h> when the system # doesn't have one that works with the given compiler. sys/socket.h: socket_.h - test -d sys || mkdir sys + @MKDIR_P@ sys { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/socket_.h; \ } > $@-t diff --git a/gl/m4/absolute-header.m4 b/gl/m4/absolute-header.m4 new file mode 100644 index 0000000000..c649df0840 --- /dev/null +++ b/gl/m4/absolute-header.m4 @@ -0,0 +1,44 @@ +# absolute-header.m4 serial 6 +dnl Copyright (C) 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Derek Price. + +# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...) +# --------------------------------------- +# Find the absolute name of a header file, assuming the header exists. +# If the header were sys/inttypes.h, this macro would define +# ABSOLUTE_SYS_INTTYPES_H to the `""' quoted absolute name of sys/inttypes.h +# in config.h +# (e.g. `#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"'). +# The three "///" are to pacify Sun C 5.8, which otherwise would say +# "warning: #include of /usr/include/... may be non-portable". +# Use `""', not `<>', so that the /// cannot be confused with a C99 comment. +AC_DEFUN([gl_ABSOLUTE_HEADER], +[AC_LANG_PREPROC_REQUIRE()dnl +AC_FOREACH([gl_HEADER_NAME], [$1], + [AS_VAR_PUSHDEF([gl_absolute_header], + [gl_cv_absolute_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl + AC_CACHE_CHECK([absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>], + m4_quote(m4_defn([gl_absolute_header])), + [AS_VAR_PUSHDEF([ac_header_exists], + [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl + AC_CHECK_HEADERS_ONCE(m4_quote(m4_defn([gl_HEADER_NAME])))dnl + if test AS_VAR_GET(ac_header_exists) = yes; then + AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])]) +dnl eval is necessary to expand ac_cpp. +dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell. + AS_VAR_SET(gl_absolute_header, +[`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | +sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#;s#^/[^/]#//&#;p;q;}'`]) + fi + AS_VAR_POPDEF([ac_header_exists])dnl + ])dnl + AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_quote(m4_defn([gl_HEADER_NAME]))), + ["AS_VAR_GET(gl_absolute_header)"], + [Define this to an absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>.]) + AS_VAR_POPDEF([gl_absolute_header])dnl +])dnl +])# gl_ABSOLUTE_HEADER diff --git a/gl/m4/extensions.m4 b/gl/m4/extensions.m4 new file mode 100644 index 0000000000..143a9e5403 --- /dev/null +++ b/gl/m4/extensions.m4 @@ -0,0 +1,58 @@ +# serial 4 -*- Autoconf -*- +# Enable extensions on systems that normally disable them. + +# Copyright (C) 2003, 2006 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS +# Autoconf. Perhaps we can remove this once we can assume Autoconf +# 2.61 or later everywhere, but since CVS Autoconf mutates rapidly +# enough in this area it's likely we'll need to redefine +# AC_USE_SYSTEM_EXTENSIONS for quite some time. + +# AC_USE_SYSTEM_EXTENSIONS +# ------------------------ +# Enable extensions on systems that normally disable them, +# typically due to standards-conformance issues. +AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], +[ + AC_BEFORE([$0], [AC_COMPILE_IFELSE]) + AC_BEFORE([$0], [AC_RUN_IFELSE]) + + AC_REQUIRE([AC_GNU_SOURCE]) + AC_REQUIRE([AC_AIX]) + AC_REQUIRE([AC_MINIX]) + + AH_VERBATIM([__EXTENSIONS__], +[/* Enable extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif]) + AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], + [ac_cv_safe_to_define___extensions__], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ +# define __EXTENSIONS__ 1 + AC_INCLUDES_DEFAULT])], + [ac_cv_safe_to_define___extensions__=yes], + [ac_cv_safe_to_define___extensions__=no])]) + test $ac_cv_safe_to_define___extensions__ = yes && + AC_DEFINE([__EXTENSIONS__]) + AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) + AC_DEFINE([_TANDEM_SOURCE]) +]) + +# gl_USE_SYSTEM_EXTENSIONS +# ------------------------ +# Enable extensions on systems that normally disable them, +# typically due to standards-conformance issues. +AC_DEFUN([gl_USE_SYSTEM_EXTENSIONS], + [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])]) diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4 index be4cb3389d..539801080d 100644 --- a/gl/m4/gnulib-common.m4 +++ b/gl/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 1 +# gnulib-common.m4 serial 2 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,3 +11,12 @@ AC_DEFUN([gl_MODULE_INDICATOR], AC_DEFINE([GNULIB_]translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1], [Define to 1 when using the gnulib module ]$1[.]) ]) + +# AC_PROG_MKDIR_P +# is a backport of autoconf-2.60's AC_PROG_MKDIR_P. +# Remove this macro when we can assume autoconf >= 2.60. +m4_ifdef([AC_PROG_MKDIR_P], [], [ + AC_DEFUN([AC_PROG_MKDIR_P], + [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake + MKDIR_P='$(mkdir_p)' + AC_SUBST([MKDIR_P])])]) diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 02ac7350c8..e2bf48a432 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -26,6 +26,7 @@ AC_DEFUN([gl_EARLY], m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable AC_REQUIRE([AC_PROG_RANLIB]) AC_REQUIRE([AC_GNU_SOURCE]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) AC_REQUIRE([gl_LOCK_EARLY]) ]) @@ -40,6 +41,7 @@ AC_DEFUN([gl_INIT], gl_cond_libtool=true gl_source_base='gl' gl_HEADER_ARPA_INET + dnl gl_USE_SYSTEM_EXTENSIONS must be added quite early to configure.ac. gl_GETADDRINFO gl_FUNC_GETDELIM gl_FUNC_GETLINE @@ -51,7 +53,9 @@ AC_DEFUN([gl_INIT], gl_TYPE_SOCKLEN_T AM_STDBOOL_H gl_FUNC_STRDUP + gl_HEADER_STRING_H gl_HEADER_SYS_SOCKET + AC_PROG_MKDIR_P m4_popdef([AC_LIBSOURCES]) m4_popdef([AC_REPLACE_FUNCS]) m4_popdef([AC_LIBOBJ]) @@ -117,8 +121,10 @@ AC_DEFUN([gl_FILE_LIST], [ lib/socket_.h lib/stdbool_.h lib/strdup.c - lib/strdup.h + lib/string_.h + m4/absolute-header.m4 m4/arpa_inet_h.m4 + m4/extensions.m4 m4/getaddrinfo.m4 m4/getdelim.m4 m4/getline.m4 @@ -135,5 +141,6 @@ AC_DEFUN([gl_FILE_LIST], [ m4/sockpfaf.m4 m4/stdbool.m4 m4/strdup.m4 + m4/string_h.m4 m4/sys_socket_h.m4 ]) diff --git a/gl/m4/strdup.m4 b/gl/m4/strdup.m4 index f7786e944b..8796e9e02f 100644 --- a/gl/m4/strdup.m4 +++ b/gl/m4/strdup.m4 @@ -1,13 +1,20 @@ -# strdup.m4 serial 7 -dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# strdup.m4 serial 9 + +dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software +dnl Foundation, Inc. + dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_STRDUP], [ + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) AC_REPLACE_FUNCS(strdup) AC_CHECK_DECLS_ONCE(strdup) + if test $ac_cv_have_decl_strdup = no; then + HAVE_DECL_STRDUP=0 + fi gl_PREREQ_STRDUP ]) diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4 new file mode 100644 index 0000000000..84db7a59ba --- /dev/null +++ b/gl/m4/string_h.m4 @@ -0,0 +1,46 @@ +# Configure a GNU-like replacement for <string.h>. + +# Copyright (C) 2007 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert. + +AC_DEFUN([gl_HEADER_STRING_H], +[ + dnl Use AC_REQUIRE here, so that the default behavior below is expanded + dnl once only, before all statements that occur in other macros. + AC_REQUIRE([gl_HEADER_STRING_H_BODY]) +]) + +AC_DEFUN([gl_HEADER_STRING_H_BODY], +[ + AC_REQUIRE([AC_C_RESTRICT]) + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + gl_ABSOLUTE_HEADER([string.h]) + ABSOLUTE_STRING_H=\"$gl_cv_absolute_string_h\" + AC_SUBST([ABSOLUTE_STRING_H]) +]) + +AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) + HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) + HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) + HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) + HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY]) + HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP]) + HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL]) + HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP]) + HAVE_STRNDUP=1; AC_SUBST([HAVE_STRNDUP]) + HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP]) + HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN]) + HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK]) + HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP]) + HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) + REPLACE_STRCASECMP=0; AC_SUBST([REPLACE_STRCASECMP]) + REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) + REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) +]) diff --git a/gl/socket_.h b/gl/socket_.h index fbf0483339..8b28b5ed39 100644 --- a/gl/socket_.h +++ b/gl/socket_.h @@ -57,4 +57,14 @@ # define SHUT_RDWR SD_BOTH #endif +#if defined _WIN32 || defined __WIN32__ +# define ENOTSOCK WSAENOTSOCK +# define EADDRINUSE WSAEADDRINUSE +# define ENETRESET WSAENETRESET +# define ECONNABORTED WSAECONNABORTED +# define ECONNRESET WSAECONNRESET +# define ENOTCONN WSAENOTCONN +# define ESHUTDOWN WSAESHUTDOWN +#endif + #endif /* _SYS_SOCKET_H */ diff --git a/gl/strdup.c b/gl/strdup.c index 17d40d622d..c614108786 100644 --- a/gl/strdup.c +++ b/gl/strdup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004, 2006 Free +/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,13 +19,13 @@ #ifndef _LIBC # include <config.h> -/* Get specification. */ -# include "strdup.h" #endif -#include <stdlib.h> +/* Get specification. */ #include <string.h> +#include <stdlib.h> + #undef __strdup #ifdef _LIBC # undef strdup diff --git a/gl/string_.h b/gl/string_.h new file mode 100644 index 0000000000..94d991cf06 --- /dev/null +++ b/gl/string_.h @@ -0,0 +1,182 @@ +/* A GNU-like <string.h>. + + Copyright (C) 1995-1996, 2001-2007 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 2, 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _GL_STRING_H +#define _GL_STRING_H + +#include @ABSOLUTE_STRING_H@ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Return the first occurrence of NEEDLE in HAYSTACK. */ +#if ! @HAVE_DECL_MEMMEM@ +extern void *memmem (void const *__haystack, size_t __haystack_len, + void const *__needle, size_t __needle_len); +#endif + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +#if ! @HAVE_MEMPCPY@ +extern void *mempcpy (void *restrict __dest, void const *restrict __src, + size_t __n); +#endif + +/* Search backwards through a block for a byte (specified as an int). */ +#if ! @HAVE_DECL_MEMRCHR@ +extern void *memrchr (void const *, int, size_t); +#endif + +/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ +#if ! @HAVE_STPCPY@ +extern char *stpcpy (char *restrict __dst, char const *restrict __src); +#endif + +/* Copy no more than N bytes of SRC to DST, returning a pointer past the + last non-NUL byte written into DST. */ +#if ! @HAVE_STPNCPY@ +# define stpncpy gnu_stpncpy +extern char *stpncpy (char *restrict __dst, char const *restrict __src, + size_t __n); +#endif + +/* Compare strings S1 and S2, ignoring case, returning less than, equal to or + greater than zero if S1 is lexicographically less than, equal to or greater + than S2. + Note: This function may, in multibyte locales, return 0 for strings of + different lengths! + No known system has a strcasecmp() function that works correctly in + multibyte locales. Therefore use our version always, if the + strcase module is available. */ +#if @REPLACE_STRCASECMP@ +# define strcasecmp rpl_strcasecmp +extern int strcasecmp (char const *__s1, char const *__s2); +#endif + +/* Compare no more than N bytes of strings S1 and S2, ignoring case, + returning less than, equal to or greater than zero if S1 is + lexicographically less than, equal to or greater than S2. + Note: This function cannot work correctly in multibyte locales. */ +#if ! @HAVE_DECL_STRNCASECMP@ +extern int strncasecmp (char const *__s1, char const *__s2, size_t __n); +#endif + +/* Find the first occurrence of C in S or the final NUL byte. */ +#if ! @HAVE_STRCHRNUL@ +extern char *strchrnul (char const *__s, int __c_in); +#endif + +/* Duplicate S, returning an identical malloc'd string. */ +#if ! @HAVE_DECL_STRDUP@ && ! defined strdup +extern char *strdup (char const *__s); +#endif + +/* Return a newly allocated copy of at most N bytes of STRING. */ +#if ! @HAVE_STRNDUP@ +# undef strndup +# define strndup rpl_strndup +# if ! @HAVE_DECL_STRNDUP@ +extern char *strndup (char const *__string, size_t __n); +# endif +#endif + +/* Find the length (number of bytes) of STRING, but scan at most + MAXLEN bytes. If no '\0' terminator is found in that many bytes, + return MAXLEN. */ +#if ! @HAVE_DECL_STRNLEN@ +extern size_t strnlen (char const *__string, size_t __maxlen); +#endif + +/* Find the first occurrence in S of any character in ACCEPT. */ +#if ! @HAVE_STRPBRK@ +extern char *strpbrk (char const *__s, char const *__accept); +#endif + +/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. + If one is found, overwrite it with a NUL, and advance *STRINGP + to point to the next char after it. Otherwise, set *STRINGP to NULL. + If *STRINGP was already NULL, nothing happens. + Return the old value of *STRINGP. + + This is a variant of strtok() that is multithread-safe and supports + empty fields. + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + Caveat: It doesn't work with multibyte strings unless all of the delimiter + characters are ASCII characters < 0x30. + + See also strtok_r(). */ +#if ! @HAVE_STRSEP@ +extern char *strsep (char **restrict __stringp, char const *restrict __delim); +#endif + +/* Find the first occurrence of NEEDLE in HAYSTACK. + No known system has a strstr() function that works correctly in + multibyte locales. Therefore use our version always, if the strstr + module is available. */ +#if @REPLACE_STRSTR@ +# undef strstr +# define strstr rpl_strstr +extern char *strstr (char const *__haystack, char const *__needle); +#endif + +/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive + comparison. + Note: This function may, in multibyte locales, return success even if + strlen (haystack) < strlen (needle) ! */ +#if @REPLACE_STRCASESTR@ +# undef strcasestr +# define strcasestr rpl_strcasestr +extern char *strcasestr (const char *haystack, const char *needle); +#endif + +/* Parse S into tokens separated by characters in DELIM. + If S is NULL, the saved pointer in SAVE_PTR is used as + the next starting point. For example: + char s[] = "-abc-=-def"; + char *sp; + x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = strtok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" + + This is a variant of strtok() that is multithread-safe. + + For the POSIX documentation for this function, see: + http://www.opengroup.org/susv3xsh/strtok.html + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + Caveat: It doesn't work with multibyte strings unless all of the delimiter + characters are ASCII characters < 0x30. + + See also strsep(). */ +#if ! @HAVE_DECL_STRTOK_R@ +extern char *strtok_r (char *restrict __s, char const *restrict __sep, + char **restrict __lasts); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lgl/Makefile.am b/lgl/Makefile.am index 4606e494ee..7db8b8dc8e 100644 --- a/lgl/Makefile.am +++ b/lgl/Makefile.am @@ -187,7 +187,7 @@ EXTRA_liblgnu_la_SOURCES += md2.c ## begin gnulib module memmem -EXTRA_DIST += memmem.c memmem.h +EXTRA_DIST += memmem.c EXTRA_liblgnu_la_SOURCES += memmem.c @@ -241,8 +241,7 @@ BUILT_SOURCES += $(STDINT_H) stdint.h: stdint_.h rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ - -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ + sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ -e 's|@''ABSOLUTE_STDINT_H''@|$(ABSOLUTE_STDINT_H)|g' \ -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ @@ -272,6 +271,42 @@ EXTRA_DIST += stdint_.h ## end gnulib module stdint +## begin gnulib module string + +BUILT_SOURCES += string.h + +# We need the following in order to create <string.h> when the system +# doesn't have one that works with the given compiler. +string.h: string_.h + rm -f $@-t $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's|@''ABSOLUTE_STRING_H''@|$(ABSOLUTE_STRING_H)|g' \ + -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ + -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ + -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ + -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \ + -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ + -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \ + -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ + -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \ + -e 's|@''HAVE_STRNDUP''@|$(HAVE_STRNDUP)|g' \ + -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \ + -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \ + -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \ + -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \ + -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ + -e 's|@''REPLACE_STRCASECMP''@|$(REPLACE_STRCASECMP)|g' \ + -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ + -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ + < $(srcdir)/string_.h; \ + } > $@-t + mv $@-t $@ +MOSTLYCLEANFILES += string.h string.h-t + +EXTRA_DIST += string_.h + +## end gnulib module string + ## begin gnulib module strverscmp @@ -288,7 +323,7 @@ BUILT_SOURCES += $(SYS_SOCKET_H) # We need the following in order to create <sys/socket.h> when the system # doesn't have one that works with the given compiler. sys/socket.h: socket_.h - test -d sys || mkdir sys + @MKDIR_P@ sys { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/socket_.h; \ } > $@-t @@ -307,7 +342,7 @@ BUILT_SOURCES += $(SYS_STAT_H) # We need the following in order to create <sys/stat.h> when the system # has one that is incomplete. sys/stat.h: stat_.h - test -d sys || mkdir sys + @MKDIR_P@ sys rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''ABSOLUTE_SYS_STAT_H''@|$(ABSOLUTE_SYS_STAT_H)|g' \ @@ -349,6 +384,25 @@ EXTRA_liblgnu_la_SOURCES += asnprintf.c printf-args.c printf-parse.c vasnprintf. ## end gnulib module vasnprintf +## begin gnulib module wchar + +BUILT_SOURCES += $(WCHAR_H) + +# We need the following in order to create <wchar.h> when the system +# version does not work standalone. +wchar.h: wchar_.h + rm -f $@-t $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''ABSOLUTE_WCHAR_H''@|$(ABSOLUTE_WCHAR_H)|g' \ + < $(srcdir)/wchar_.h; \ + } > $@-t + mv $@-t $@ +MOSTLYCLEANFILES += wchar.h wchar.h-t + +EXTRA_DIST += wchar_.h + +## end gnulib module wchar + ## begin gnulib module xsize liblgnu_la_SOURCES += xsize.h diff --git a/lgl/m4/extensions.m4 b/lgl/m4/extensions.m4 new file mode 100644 index 0000000000..143a9e5403 --- /dev/null +++ b/lgl/m4/extensions.m4 @@ -0,0 +1,58 @@ +# serial 4 -*- Autoconf -*- +# Enable extensions on systems that normally disable them. + +# Copyright (C) 2003, 2006 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS +# Autoconf. Perhaps we can remove this once we can assume Autoconf +# 2.61 or later everywhere, but since CVS Autoconf mutates rapidly +# enough in this area it's likely we'll need to redefine +# AC_USE_SYSTEM_EXTENSIONS for quite some time. + +# AC_USE_SYSTEM_EXTENSIONS +# ------------------------ +# Enable extensions on systems that normally disable them, +# typically due to standards-conformance issues. +AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], +[ + AC_BEFORE([$0], [AC_COMPILE_IFELSE]) + AC_BEFORE([$0], [AC_RUN_IFELSE]) + + AC_REQUIRE([AC_GNU_SOURCE]) + AC_REQUIRE([AC_AIX]) + AC_REQUIRE([AC_MINIX]) + + AH_VERBATIM([__EXTENSIONS__], +[/* Enable extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif]) + AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], + [ac_cv_safe_to_define___extensions__], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ +# define __EXTENSIONS__ 1 + AC_INCLUDES_DEFAULT])], + [ac_cv_safe_to_define___extensions__=yes], + [ac_cv_safe_to_define___extensions__=no])]) + test $ac_cv_safe_to_define___extensions__ = yes && + AC_DEFINE([__EXTENSIONS__]) + AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) + AC_DEFINE([_TANDEM_SOURCE]) +]) + +# gl_USE_SYSTEM_EXTENSIONS +# ------------------------ +# Enable extensions on systems that normally disable them, +# typically due to standards-conformance issues. +AC_DEFUN([gl_USE_SYSTEM_EXTENSIONS], + [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])]) diff --git a/lgl/m4/gnulib-common.m4 b/lgl/m4/gnulib-common.m4 index be4cb3389d..539801080d 100644 --- a/lgl/m4/gnulib-common.m4 +++ b/lgl/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 1 +# gnulib-common.m4 serial 2 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,3 +11,12 @@ AC_DEFUN([gl_MODULE_INDICATOR], AC_DEFINE([GNULIB_]translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1], [Define to 1 when using the gnulib module ]$1[.]) ]) + +# AC_PROG_MKDIR_P +# is a backport of autoconf-2.60's AC_PROG_MKDIR_P. +# Remove this macro when we can assume autoconf >= 2.60. +m4_ifdef([AC_PROG_MKDIR_P], [], [ + AC_DEFUN([AC_PROG_MKDIR_P], + [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake + MKDIR_P='$(mkdir_p)' + AC_SUBST([MKDIR_P])])]) diff --git a/lgl/m4/gnulib-comp.m4 b/lgl/m4/gnulib-comp.m4 index 2f3dac84d7..3ebad02bf5 100644 --- a/lgl/m4/gnulib-comp.m4 +++ b/lgl/m4/gnulib-comp.m4 @@ -26,6 +26,7 @@ AC_DEFUN([lgl_EARLY], m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable AC_REQUIRE([AC_PROG_RANLIB]) AC_REQUIRE([AC_GNU_SOURCE]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) AC_REQUIRE([gl_LOCK_EARLY]) ]) @@ -40,6 +41,7 @@ AC_DEFUN([lgl_INIT], gl_cond_libtool=true gl_source_base='lgl' gl_FUNC_ALLOCA + dnl gl_USE_SYSTEM_EXTENSIONS must be added quite early to configure.ac. gl_GC if test $gl_cond_libtool = false; then gl_ltlibdeps="$gl_ltlibdeps $LTLIBGCRYPT" @@ -79,11 +81,15 @@ AC_DEFUN([lgl_INIT], gl_FUNC_SNPRINTF gl_TYPE_SOCKLEN_T gl_STDINT_H + gl_HEADER_STRING_H gl_FUNC_STRVERSCMP gl_HEADER_SYS_SOCKET + AC_PROG_MKDIR_P gl_HEADER_SYS_STAT_H + AC_PROG_MKDIR_P gl_HEADER_UNISTD gl_FUNC_VASNPRINTF + gl_WCHAR_H gl_XSIZE m4_popdef([AC_LIBSOURCES]) m4_popdef([AC_REPLACE_FUNCS]) @@ -147,7 +153,6 @@ AC_DEFUN([lgl_FILE_LIST], [ lib/md5.c lib/md5.h lib/memmem.c - lib/memmem.h lib/memmove.c lib/memxor.c lib/memxor.h @@ -170,11 +175,13 @@ AC_DEFUN([lgl_FILE_LIST], [ lib/socket_.h lib/stat_.h lib/stdint_.h + lib/string_.h lib/strverscmp.c lib/strverscmp.h lib/unistd_.h lib/vasnprintf.c lib/vasnprintf.h + lib/wchar_.h lib/xsize.h m4/absolute-header.m4 m4/alloca.m4 @@ -183,6 +190,7 @@ AC_DEFUN([lgl_FILE_LIST], [ m4/codeset.m4 m4/des.m4 m4/eoverflow.m4 + m4/extensions.m4 m4/gc-arcfour.m4 m4/gc-arctwo.m4 m4/gc-des.m4 @@ -237,6 +245,7 @@ AC_DEFUN([lgl_FILE_LIST], [ m4/sockpfaf.m4 m4/stdint.m4 m4/stdint_h.m4 + m4/string_h.m4 m4/strverscmp.m4 m4/sys_socket_h.m4 m4/sys_stat_h.m4 @@ -245,6 +254,7 @@ AC_DEFUN([lgl_FILE_LIST], [ m4/unistd_h.m4 m4/vasnprintf.m4 m4/visibility.m4 + m4/wchar.m4 m4/wchar_t.m4 m4/wint_t.m4 m4/xsize.m4 diff --git a/lgl/m4/memmem.m4 b/lgl/m4/memmem.m4 index 86072eaac1..e6d40068e4 100644 --- a/lgl/m4/memmem.m4 +++ b/lgl/m4/memmem.m4 @@ -1,5 +1,5 @@ -# memmem.m4 serial 2 -dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. +# memmem.m4 serial 4 +dnl Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -9,8 +9,12 @@ AC_DEFUN([gl_FUNC_MEMMEM], dnl Persuade glibc <string.h> to declare memmem(). AC_REQUIRE([AC_GNU_SOURCE]) + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) AC_REPLACE_FUNCS(memmem) AC_CHECK_DECLS_ONCE(memmem) + if test $ac_cv_have_decl_memmem = no; then + HAVE_DECL_MEMMEM=0 + fi gl_PREREQ_MEMMEM ]) diff --git a/lgl/m4/stdint.m4 b/lgl/m4/stdint.m4 index 92cb832b1b..1a4b4a6a36 100644 --- a/lgl/m4/stdint.m4 +++ b/lgl/m4/stdint.m4 @@ -1,5 +1,5 @@ -# stdint.m4 serial 21 -dnl Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc. +# stdint.m4 serial 22 +dnl Copyright (C) 2001-2002, 2004-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -27,15 +27,6 @@ AC_DEFUN([gl_STDINT_H], fi AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT]) - dnl Check for <wchar.h>. - AC_CHECK_HEADERS_ONCE([wchar.h]) - if test $ac_cv_header_wchar_h = yes; then - HAVE_WCHAR_H=1 - else - HAVE_WCHAR_H=0 - fi - AC_SUBST([HAVE_WCHAR_H]) - dnl Check for <inttypes.h>. dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h. if test $ac_cv_header_inttypes_h = yes; then @@ -75,7 +66,7 @@ AC_DEFUN([gl_STDINT_H], [gl_cv_header_working_stdint_h], [gl_cv_header_working_stdint_h=no AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ + AC_LANG_PROGRAM([[ #include <stddef.h> #define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */ #define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */ @@ -160,9 +151,9 @@ struct s { /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */ int check_UINT8_C: - (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1; + (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1; int check_UINT16_C: - (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1; + (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1; /* Detect bugs in OpenBSD 3.9 stdint.h. */ #ifdef UINT8_MAX @@ -189,7 +180,7 @@ struct s { int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1; int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1; }; - ]])], + ]])], [gl_cv_header_working_stdint_h=yes])]) fi if test "$gl_cv_header_working_stdint_h" = yes; then @@ -231,7 +222,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF], for gltype in $1 ; do AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}], [AC_COMPUTE_INT([result], [sizeof ($gltype) * CHAR_BIT], - [$2 + [$2 #include <limits.h>], [result=unknown]) eval gl_cv_bitsizeof_${gltype}=\$result ]) @@ -299,35 +290,35 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], AC_FOREACH([gltype], [$1], [AH_TEMPLATE(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], [Define to l, ll, u, ul, ull, etc., as suitable for - constants of type ']gltype['.])]) + constants of type ']gltype['.])]) for gltype in $1 ; do AC_CACHE_CHECK([for $gltype integer literal suffix], [gl_cv_type_${gltype}_suffix], [eval gl_cv_type_${gltype}_suffix=no eval result=\$gl_cv_type_${gltype}_signed if test "$result" = yes; then - glsufu= + glsufu= else - glsufu=u + glsufu=u fi for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do - case $glsuf in - '') gltype1='int';; - l) gltype1='long int';; - ll) gltype1='long long int';; - i64) gltype1='__int64';; - u) gltype1='unsigned int';; - ul) gltype1='unsigned long int';; - ull) gltype1='unsigned long long int';; - ui64)gltype1='unsigned __int64';; - esac - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([$2 - extern $gltype foo; - extern $gltype1 foo;])], - [eval gl_cv_type_${gltype}_suffix=\$glsuf]) - eval result=\$gl_cv_type_${gltype}_suffix - test "$result" != no && break + case $glsuf in + '') gltype1='int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + i64) gltype1='__int64';; + u) gltype1='unsigned int';; + ul) gltype1='unsigned long int';; + ull) gltype1='unsigned long long int';; + ui64)gltype1='unsigned __int64';; + esac + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([$2 + extern $gltype foo; + extern $gltype1 foo;])], + [eval gl_cv_type_${gltype}_suffix=\$glsuf]) + eval result=\$gl_cv_type_${gltype}_suffix + test "$result" != no && break done]) GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` eval result=\$gl_cv_type_${gltype}_suffix @@ -342,15 +333,13 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], dnl gl_STDINT_INCLUDES AC_DEFUN([gl_STDINT_INCLUDES], [[ + /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be + included before <wchar.h>. */ #include <stddef.h> #include <signal.h> - #if HAVE_WCHAR_H - /* BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before - <wchar.h>. */ - # include <stdio.h> - # include <time.h> - # include <wchar.h> - #endif + #include <stdio.h> + #include <time.h> + #include <wchar.h> ]]) dnl gl_STDINT_TYPE_PROPERTIES @@ -373,3 +362,8 @@ dnl Remove this when we can assume autoconf >= 2.61. m4_ifdef([AC_COMPUTE_INT], [], [ AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])]) ]) + +# Hey Emacs! +# Local Variables: +# indent-tabs-mode: nil +# End: diff --git a/lgl/m4/string_h.m4 b/lgl/m4/string_h.m4 new file mode 100644 index 0000000000..84db7a59ba --- /dev/null +++ b/lgl/m4/string_h.m4 @@ -0,0 +1,46 @@ +# Configure a GNU-like replacement for <string.h>. + +# Copyright (C) 2007 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert. + +AC_DEFUN([gl_HEADER_STRING_H], +[ + dnl Use AC_REQUIRE here, so that the default behavior below is expanded + dnl once only, before all statements that occur in other macros. + AC_REQUIRE([gl_HEADER_STRING_H_BODY]) +]) + +AC_DEFUN([gl_HEADER_STRING_H_BODY], +[ + AC_REQUIRE([AC_C_RESTRICT]) + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + gl_ABSOLUTE_HEADER([string.h]) + ABSOLUTE_STRING_H=\"$gl_cv_absolute_string_h\" + AC_SUBST([ABSOLUTE_STRING_H]) +]) + +AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) + HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) + HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) + HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) + HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY]) + HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP]) + HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL]) + HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP]) + HAVE_STRNDUP=1; AC_SUBST([HAVE_STRNDUP]) + HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP]) + HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN]) + HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK]) + HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP]) + HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) + REPLACE_STRCASECMP=0; AC_SUBST([REPLACE_STRCASECMP]) + REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) + REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) +]) diff --git a/lgl/m4/unistd_h.m4 b/lgl/m4/unistd_h.m4 index 9d499dfe84..d38de90fe8 100644 --- a/lgl/m4/unistd_h.m4 +++ b/lgl/m4/unistd_h.m4 @@ -1,5 +1,5 @@ -# unistd_h.m4 serial 3 -dnl Copyright (C) 2006 Free Software Foundation, Inc. +# unistd_h.m4 serial 4 +dnl Copyright (C) 2006-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -8,12 +8,13 @@ dnl Written by Simon Josefsson AC_DEFUN([gl_HEADER_UNISTD], [ - AC_CHECK_HEADERS([unistd.h], [ - UNISTD_H='' - ], [ + dnl Use AC_REQUIRE here, so that the default behavior below is expanded + dnl once only, before all statements that occur in other macros. + AC_REQUIRE([gl_HEADER_UNISTD_DEFAULTS]) + + AC_CHECK_HEADERS([unistd.h], [], [ UNISTD_H='unistd.h' ]) - AC_SUBST(UNISTD_H) dnl This module decides to build unistd.h if it is missing. dnl The fchdir module decides to build unistd.h if fchdir() is missing. dnl Therefore check for the prerequisites of lib/unistd.h always. @@ -30,3 +31,9 @@ AC_DEFUN([gl_PREREQ_UNISTD], fi AC_SUBST([ABSOLUTE_UNISTD_H]) ]) + +AC_DEFUN([gl_HEADER_UNISTD_DEFAULTS], +[ + UNISTD_H= + AC_SUBST(UNISTD_H) +]) diff --git a/lgl/m4/wchar.m4 b/lgl/m4/wchar.m4 new file mode 100644 index 0000000000..068f22d31b --- /dev/null +++ b/lgl/m4/wchar.m4 @@ -0,0 +1,29 @@ +dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues. + +dnl Copyright (C) 2007 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Eric Blake. + +# wchar.m4 serial 1 + +AC_DEFUN([gl_WCHAR_H], +[ + AC_CACHE_CHECK([whether <wchar.h> is standalone], + [gl_cv_header_wchar_h_standalone], + [AC_COMPILE_IFELSE([[#include <wchar.h> +wchar_t w;]], + [gl_cv_header_wchar_h_standalone=yes], + [gl_cv_header_wchar_h_standalone=no])]) + if test $gl_cv_header_wchar_h_standalone = yes; then + WCHAR_H= + else + gl_ABSOLUTE_HEADER([wchar.h]) + ABSOLUTE_WCHAR_H=\"$gl_cv_absolute_wchar_h\" + WCHAR_H=wchar.h + fi + AC_SUBST([ABSOLUTE_WCHAR_H]) + AC_SUBST([WCHAR_H]) +]) diff --git a/lgl/printf-args.c b/lgl/printf-args.c index ea76f29c50..f371375ef9 100644 --- a/lgl/printf-args.c +++ b/lgl/printf-args.c @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2005-2006 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2003, 2005-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -56,7 +56,7 @@ printf_fetchargs (va_list args, arguments *a) case TYPE_ULONGINT: ap->a.a_ulongint = va_arg (args, unsigned long int); break; -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT case TYPE_LONGLONGINT: ap->a.a_longlongint = va_arg (args, long long int); break; @@ -67,7 +67,7 @@ printf_fetchargs (va_list args, arguments *a) case TYPE_DOUBLE: ap->a.a_double = va_arg (args, double); break; -#ifdef HAVE_LONG_DOUBLE +#if HAVE_LONG_DOUBLE case TYPE_LONGDOUBLE: ap->a.a_longdouble = va_arg (args, long double); break; @@ -75,7 +75,7 @@ printf_fetchargs (va_list args, arguments *a) case TYPE_CHAR: ap->a.a_char = va_arg (args, int); break; -#ifdef HAVE_WINT_T +#if HAVE_WINT_T case TYPE_WIDE_CHAR: /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by default argument promotions", this is not the case in mingw32, @@ -94,7 +94,7 @@ printf_fetchargs (va_list args, arguments *a) if (ap->a.a_string == NULL) ap->a.a_string = "(NULL)"; break; -#ifdef HAVE_WCHAR_T +#if HAVE_WCHAR_T case TYPE_WIDE_STRING: ap->a.a_wide_string = va_arg (args, const wchar_t *); /* A null pointer is an invalid argument for "%ls", but in practice @@ -128,7 +128,7 @@ printf_fetchargs (va_list args, arguments *a) case TYPE_COUNT_LONGINT_POINTER: ap->a.a_count_longint_pointer = va_arg (args, long int *); break; -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT case TYPE_COUNT_LONGLONGINT_POINTER: ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); break; diff --git a/lgl/printf-args.h b/lgl/printf-args.h index 4a4e972377..e3247ac70d 100644 --- a/lgl/printf-args.h +++ b/lgl/printf-args.h @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2006 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2003, 2006-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -22,12 +22,12 @@ #include <stddef.h> /* Get wchar_t. */ -#ifdef HAVE_WCHAR_T +#if HAVE_WCHAR_T # include <stddef.h> #endif /* Get wint_t. */ -#ifdef HAVE_WINT_T +#if HAVE_WINT_T # include <wchar.h> #endif @@ -47,20 +47,20 @@ typedef enum TYPE_UINT, TYPE_LONGINT, TYPE_ULONGINT, -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT TYPE_LONGLONGINT, TYPE_ULONGLONGINT, #endif TYPE_DOUBLE, -#ifdef HAVE_LONG_DOUBLE +#if HAVE_LONG_DOUBLE TYPE_LONGDOUBLE, #endif TYPE_CHAR, -#ifdef HAVE_WINT_T +#if HAVE_WINT_T TYPE_WIDE_CHAR, #endif TYPE_STRING, -#ifdef HAVE_WCHAR_T +#if HAVE_WCHAR_T TYPE_WIDE_STRING, #endif TYPE_POINTER, @@ -68,7 +68,7 @@ typedef enum TYPE_COUNT_SHORT_POINTER, TYPE_COUNT_INT_POINTER, TYPE_COUNT_LONGINT_POINTER -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT , TYPE_COUNT_LONGLONGINT_POINTER #endif } arg_type; @@ -87,21 +87,21 @@ typedef struct unsigned int a_uint; long int a_longint; unsigned long int a_ulongint; -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT long long int a_longlongint; unsigned long long int a_ulonglongint; #endif float a_float; double a_double; -#ifdef HAVE_LONG_DOUBLE +#if HAVE_LONG_DOUBLE long double a_longdouble; #endif int a_char; -#ifdef HAVE_WINT_T +#if HAVE_WINT_T wint_t a_wide_char; #endif const char* a_string; -#ifdef HAVE_WCHAR_T +#if HAVE_WCHAR_T const wchar_t* a_wide_string; #endif void* a_pointer; @@ -109,7 +109,7 @@ typedef struct short * a_count_short_pointer; int * a_count_int_pointer; long int * a_count_longint_pointer; -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT long long int * a_count_longlongint_pointer; #endif } diff --git a/lgl/printf-parse.c b/lgl/printf-parse.c index 4256eced09..6fe2d2d8a6 100644 --- a/lgl/printf-parse.c +++ b/lgl/printf-parse.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999-2000, 2002-2003, 2006 Free Software Foundation, Inc. + Copyright (C) 1999-2000, 2002-2003, 2006-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -326,7 +326,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) flags += 8; cp++; } -#ifdef HAVE_INTMAX_T +#if HAVE_INTMAX_T else if (*cp == 'j') { if (sizeof (intmax_t) > sizeof (long)) @@ -382,7 +382,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) switch (c) { case 'd': case 'i': -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT /* If 'long long' exists and is larger than 'long': */ if (flags >= 16 || (flags & 4)) type = TYPE_LONGLONGINT; @@ -400,7 +400,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) type = TYPE_INT; break; case 'o': case 'u': case 'x': case 'X': -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT /* If 'long long' exists and is larger than 'long': */ if (flags >= 16 || (flags & 4)) type = TYPE_ULONGLONGINT; @@ -419,7 +419,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) break; case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': case 'a': case 'A': -#ifdef HAVE_LONG_DOUBLE +#if HAVE_LONG_DOUBLE if (flags >= 16 || (flags & 4)) type = TYPE_LONGDOUBLE; else @@ -428,7 +428,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) break; case 'c': if (flags >= 8) -#ifdef HAVE_WINT_T +#if HAVE_WINT_T type = TYPE_WIDE_CHAR; #else goto error; @@ -436,7 +436,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) else type = TYPE_CHAR; break; -#ifdef HAVE_WINT_T +#if HAVE_WINT_T case 'C': type = TYPE_WIDE_CHAR; c = 'c'; @@ -444,7 +444,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) #endif case 's': if (flags >= 8) -#ifdef HAVE_WCHAR_T +#if HAVE_WCHAR_T type = TYPE_WIDE_STRING; #else goto error; @@ -452,7 +452,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) else type = TYPE_STRING; break; -#ifdef HAVE_WCHAR_T +#if HAVE_WCHAR_T case 'S': type = TYPE_WIDE_STRING; c = 's'; @@ -462,7 +462,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) type = TYPE_POINTER; break; case 'n': -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT /* If 'long long' exists and is larger than 'long': */ if (flags >= 16 || (flags & 4)) type = TYPE_COUNT_LONGLONGINT_POINTER; diff --git a/lgl/socket_.h b/lgl/socket_.h index d5e1e599ff..3f104b7df4 100644 --- a/lgl/socket_.h +++ b/lgl/socket_.h @@ -57,4 +57,14 @@ # define SHUT_RDWR SD_BOTH #endif +#if defined _WIN32 || defined __WIN32__ +# define ENOTSOCK WSAENOTSOCK +# define EADDRINUSE WSAEADDRINUSE +# define ENETRESET WSAENETRESET +# define ECONNABORTED WSAECONNABORTED +# define ECONNRESET WSAECONNRESET +# define ENOTCONN WSAENOTCONN +# define ESHUTDOWN WSAESHUTDOWN +#endif + #endif /* _SYS_SOCKET_H */ diff --git a/lgl/stdint_.h b/lgl/stdint_.h index 67eeb604ec..c04b0c9c4b 100644 --- a/lgl/stdint_.h +++ b/lgl/stdint_.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc. +/* Copyright (C) 2001-2002, 2004-2007 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. This file is part of gnulib. @@ -82,11 +82,7 @@ #if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS /* Get WCHAR_MIN, WCHAR_MAX. */ -# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) - /* BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before - <wchar.h>. */ -# include <stdio.h> -# include <time.h> +# if ! (defined WCHAR_MIN && defined WCHAR_MAX) # include <wchar.h> # endif diff --git a/lgl/string_.h b/lgl/string_.h new file mode 100644 index 0000000000..617a51b9df --- /dev/null +++ b/lgl/string_.h @@ -0,0 +1,182 @@ +/* A GNU-like <string.h>. + + Copyright (C) 1995-1996, 2001-2007 Free Software Foundation, Inc. + + This program 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, 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 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _GL_STRING_H +#define _GL_STRING_H + +#include @ABSOLUTE_STRING_H@ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Return the first occurrence of NEEDLE in HAYSTACK. */ +#if ! @HAVE_DECL_MEMMEM@ +extern void *memmem (void const *__haystack, size_t __haystack_len, + void const *__needle, size_t __needle_len); +#endif + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +#if ! @HAVE_MEMPCPY@ +extern void *mempcpy (void *restrict __dest, void const *restrict __src, + size_t __n); +#endif + +/* Search backwards through a block for a byte (specified as an int). */ +#if ! @HAVE_DECL_MEMRCHR@ +extern void *memrchr (void const *, int, size_t); +#endif + +/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ +#if ! @HAVE_STPCPY@ +extern char *stpcpy (char *restrict __dst, char const *restrict __src); +#endif + +/* Copy no more than N bytes of SRC to DST, returning a pointer past the + last non-NUL byte written into DST. */ +#if ! @HAVE_STPNCPY@ +# define stpncpy gnu_stpncpy +extern char *stpncpy (char *restrict __dst, char const *restrict __src, + size_t __n); +#endif + +/* Compare strings S1 and S2, ignoring case, returning less than, equal to or + greater than zero if S1 is lexicographically less than, equal to or greater + than S2. + Note: This function may, in multibyte locales, return 0 for strings of + different lengths! + No known system has a strcasecmp() function that works correctly in + multibyte locales. Therefore use our version always, if the + strcase module is available. */ +#if @REPLACE_STRCASECMP@ +# define strcasecmp rpl_strcasecmp +extern int strcasecmp (char const *__s1, char const *__s2); +#endif + +/* Compare no more than N bytes of strings S1 and S2, ignoring case, + returning less than, equal to or greater than zero if S1 is + lexicographically less than, equal to or greater than S2. + Note: This function cannot work correctly in multibyte locales. */ +#if ! @HAVE_DECL_STRNCASECMP@ +extern int strncasecmp (char const *__s1, char const *__s2, size_t __n); +#endif + +/* Find the first occurrence of C in S or the final NUL byte. */ +#if ! @HAVE_STRCHRNUL@ +extern char *strchrnul (char const *__s, int __c_in); +#endif + +/* Duplicate S, returning an identical malloc'd string. */ +#if ! @HAVE_DECL_STRDUP@ && ! defined strdup +extern char *strdup (char const *__s); +#endif + +/* Return a newly allocated copy of at most N bytes of STRING. */ +#if ! @HAVE_STRNDUP@ +# undef strndup +# define strndup rpl_strndup +# if ! @HAVE_DECL_STRNDUP@ +extern char *strndup (char const *__string, size_t __n); +# endif +#endif + +/* Find the length (number of bytes) of STRING, but scan at most + MAXLEN bytes. If no '\0' terminator is found in that many bytes, + return MAXLEN. */ +#if ! @HAVE_DECL_STRNLEN@ +extern size_t strnlen (char const *__string, size_t __maxlen); +#endif + +/* Find the first occurrence in S of any character in ACCEPT. */ +#if ! @HAVE_STRPBRK@ +extern char *strpbrk (char const *__s, char const *__accept); +#endif + +/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. + If one is found, overwrite it with a NUL, and advance *STRINGP + to point to the next char after it. Otherwise, set *STRINGP to NULL. + If *STRINGP was already NULL, nothing happens. + Return the old value of *STRINGP. + + This is a variant of strtok() that is multithread-safe and supports + empty fields. + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + Caveat: It doesn't work with multibyte strings unless all of the delimiter + characters are ASCII characters < 0x30. + + See also strtok_r(). */ +#if ! @HAVE_STRSEP@ +extern char *strsep (char **restrict __stringp, char const *restrict __delim); +#endif + +/* Find the first occurrence of NEEDLE in HAYSTACK. + No known system has a strstr() function that works correctly in + multibyte locales. Therefore use our version always, if the strstr + module is available. */ +#if @REPLACE_STRSTR@ +# undef strstr +# define strstr rpl_strstr +extern char *strstr (char const *__haystack, char const *__needle); +#endif + +/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive + comparison. + Note: This function may, in multibyte locales, return success even if + strlen (haystack) < strlen (needle) ! */ +#if @REPLACE_STRCASESTR@ +# undef strcasestr +# define strcasestr rpl_strcasestr +extern char *strcasestr (const char *haystack, const char *needle); +#endif + +/* Parse S into tokens separated by characters in DELIM. + If S is NULL, the saved pointer in SAVE_PTR is used as + the next starting point. For example: + char s[] = "-abc-=-def"; + char *sp; + x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = strtok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" + + This is a variant of strtok() that is multithread-safe. + + For the POSIX documentation for this function, see: + http://www.opengroup.org/susv3xsh/strtok.html + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + Caveat: It doesn't work with multibyte strings unless all of the delimiter + characters are ASCII characters < 0x30. + + See also strsep(). */ +#if ! @HAVE_DECL_STRTOK_R@ +extern char *strtok_r (char *restrict __s, char const *restrict __sep, + char **restrict __lasts); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lgl/vasnprintf.c b/lgl/vasnprintf.c index 8f6730468b..8e5c8c39f5 100644 --- a/lgl/vasnprintf.c +++ b/lgl/vasnprintf.c @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2006 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -49,8 +49,8 @@ /* Checked size_t computations. */ #include "xsize.h" -#ifdef HAVE_WCHAR_T -# ifdef HAVE_WCSLEN +#if HAVE_WCHAR_T +# if HAVE_WCSLEN # define local_wcslen wcslen # else /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid @@ -248,7 +248,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar case TYPE_COUNT_LONGINT_POINTER: *a.arg[dp->arg_index].a.a_count_longint_pointer = length; break; -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT case TYPE_COUNT_LONGLONGINT_POINTER: *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; break; @@ -322,7 +322,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar { case 'd': case 'i': case 'u': -# ifdef HAVE_LONG_LONG_INT +# if HAVE_LONG_LONG_INT if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT @@ -352,7 +352,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar break; case 'o': -# ifdef HAVE_LONG_LONG_INT +# if HAVE_LONG_LONG_INT if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT @@ -380,7 +380,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar break; case 'x': case 'X': -# ifdef HAVE_LONG_LONG_INT +# if HAVE_LONG_LONG_INT if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT @@ -408,7 +408,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar break; case 'f': case 'F': -# ifdef HAVE_LONG_DOUBLE +# if HAVE_LONG_DOUBLE if (type == TYPE_LONGDOUBLE) tmp_length = (unsigned int) (LDBL_MAX_EXP @@ -437,7 +437,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar break; case 'c': -# if defined HAVE_WINT_T && !WIDE_CHAR_VERSION +# if HAVE_WINT_T && !WIDE_CHAR_VERSION if (type == TYPE_WIDE_CHAR) tmp_length = MB_CUR_MAX; else @@ -446,7 +446,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar break; case 's': -# ifdef HAVE_WCHAR_T +# if HAVE_WCHAR_T if (type == TYPE_WIDE_STRING) { tmp_length = @@ -527,7 +527,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar switch (type) { -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT case TYPE_LONGLONGINT: case TYPE_ULONGLONGINT: *p++ = 'l'; @@ -535,15 +535,15 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar #endif case TYPE_LONGINT: case TYPE_ULONGINT: -#ifdef HAVE_WINT_T +#if HAVE_WINT_T case TYPE_WIDE_CHAR: #endif -#ifdef HAVE_WCHAR_T +#if HAVE_WCHAR_T case TYPE_WIDE_STRING: #endif *p++ = 'l'; break; -#ifdef HAVE_LONG_DOUBLE +#if HAVE_LONG_DOUBLE case TYPE_LONGDOUBLE: *p++ = 'L'; break; @@ -681,7 +681,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar SNPRINTF_BUF (arg); } break; -#ifdef HAVE_LONG_LONG_INT +#if HAVE_LONG_LONG_INT case TYPE_LONGLONGINT: { long long int arg = a.arg[dp->arg_index].a.a_longlongint; @@ -701,7 +701,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar SNPRINTF_BUF (arg); } break; -#ifdef HAVE_LONG_DOUBLE +#if HAVE_LONG_DOUBLE case TYPE_LONGDOUBLE: { long double arg = a.arg[dp->arg_index].a.a_longdouble; @@ -715,7 +715,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar SNPRINTF_BUF (arg); } break; -#ifdef HAVE_WINT_T +#if HAVE_WINT_T case TYPE_WIDE_CHAR: { wint_t arg = a.arg[dp->arg_index].a.a_wide_char; @@ -729,7 +729,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar SNPRINTF_BUF (arg); } break; -#ifdef HAVE_WCHAR_T +#if HAVE_WCHAR_T case TYPE_WIDE_STRING: { const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; diff --git a/lgl/wchar_.h b/lgl/wchar_.h new file mode 100644 index 0000000000..790e0c24d8 --- /dev/null +++ b/lgl/wchar_.h @@ -0,0 +1,42 @@ +/* A substitute for ISO C99 <wchar.h>, for platforms that have issues. + + Copyright (C) 2007 Free Software Foundation, Inc. + + This program 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, 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 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Eric Blake. */ + +/* + * ISO C 99 <wchar.h> for platforms that have issues. + * <http://www.opengroup.org/susv3xbd/wchar.h.html> + * + * For now, this just ensures proper prerequisite inclusion order. + */ + +#ifndef _GL_WCHAR_H +#define _GL_WCHAR_H + +/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before + <wchar.h>. + BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be + included before <wchar.h>. */ +#include <stddef.h> +#include <stdio.h> +#include <time.h> + +/* Include the original <wchar.h>. */ +#include @ABSOLUTE_WCHAR_H@ + +#endif /* _GL_WCHAR_H */ |