summaryrefslogtreecommitdiff
path: root/lgl
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2007-02-04 11:28:18 +0000
committerSimon Josefsson <simon@josefsson.org>2007-02-04 11:28:18 +0000
commit37b20a82c3aac17b4559b6195180ed413d5e6622 (patch)
tree82008c106b318964dc5955de680df3f5ad0f3df8 /lgl
parent673da70556585c697380d470058cdde630dc00a6 (diff)
downloadgnutls-37b20a82c3aac17b4559b6195180ed413d5e6622.tar.gz
Update.
Diffstat (limited to 'lgl')
-rw-r--r--lgl/Makefile.am15
-rw-r--r--lgl/m4/gnulib-comp.m41
-rw-r--r--lgl/m4/socklen.m46
-rw-r--r--lgl/m4/string_h.m427
-rw-r--r--lgl/string_.h170
5 files changed, 191 insertions, 28 deletions
diff --git a/lgl/Makefile.am b/lgl/Makefile.am
index 7db8b8dc8e..c977a161ba 100644
--- a/lgl/Makefile.am
+++ b/lgl/Makefile.am
@@ -281,6 +281,21 @@ 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|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \
+ -e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \
+ -e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \
+ -e 's|@''GNULIB_STPCPY''@|$(GNULIB_STPCPY)|g' \
+ -e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \
+ -e 's|@''GNULIB_STRCASE''@|$(GNULIB_STRCASE)|g' \
+ -e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \
+ -e 's|@''GNULIB_STRDUP''@|$(GNULIB_STRDUP)|g' \
+ -e 's|@''GNULIB_STRNDUP''@|$(GNULIB_STRNDUP)|g' \
+ -e 's|@''GNULIB_STRNLEN''@|$(GNULIB_STRNLEN)|g' \
+ -e 's|@''GNULIB_STRPBRK''@|$(GNULIB_STRPBRK)|g' \
+ -e 's|@''GNULIB_STRSEP''@|$(GNULIB_STRSEP)|g' \
+ -e 's|@''GNULIB_STRSTR''@|$(GNULIB_STRSTR)|g' \
+ -e 's|@''GNULIB_STRCASESTR''@|$(GNULIB_STRCASESTR)|g' \
+ -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|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' \
diff --git a/lgl/m4/gnulib-comp.m4 b/lgl/m4/gnulib-comp.m4
index 3ebad02bf5..87028debd9 100644
--- a/lgl/m4/gnulib-comp.m4
+++ b/lgl/m4/gnulib-comp.m4
@@ -74,6 +74,7 @@ AC_DEFUN([lgl_INIT],
AM_GNU_GETTEXT_VERSION([0.15])
gl_MD2
gl_FUNC_MEMMEM
+ gl_STRING_MODULE_INDICATOR([memmem])
gl_FUNC_MEMMOVE
gl_MINMAX
gl_FUNC_READ_FILE
diff --git a/lgl/m4/socklen.m4 b/lgl/m4/socklen.m4
index 5e3765a64b..e824a09f56 100644
--- a/lgl/m4/socklen.m4
+++ b/lgl/m4/socklen.m4
@@ -1,5 +1,5 @@
-# socklen.m4 serial 4
-dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+# socklen.m4 serial 5
+dnl Copyright (C) 2005, 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.
@@ -19,7 +19,7 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
[AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl
AC_CHECK_TYPE([socklen_t], ,
[AC_MSG_CHECKING([for socklen_t equivalent])
- AC_CACHE_VAL([gl_cv_gl_cv_socklen_t_equiv],
+ AC_CACHE_VAL([gl_cv_socklen_t_equiv],
[# Systems have either "struct sockaddr *" or
# "void *" as the second argument to getpeername
gl_cv_socklen_t_equiv=
diff --git a/lgl/m4/string_h.m4 b/lgl/m4/string_h.m4
index 84db7a59ba..8e0be44f85 100644
--- a/lgl/m4/string_h.m4
+++ b/lgl/m4/string_h.m4
@@ -18,6 +18,7 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
[
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_REQUIRE([gl_STRING_MODULE_INDICATOR_DEFAULTS])
gl_ABSOLUTE_HEADER([string.h])
ABSOLUTE_STRING_H=\"$gl_cv_absolute_string_h\"
AC_SUBST([ABSOLUTE_STRING_H])
@@ -44,3 +45,29 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
])
+
+AC_DEFUN([gl_STRING_MODULE_INDICATOR],
+[
+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+ AC_REQUIRE([gl_STRING_MODULE_INDICATOR_DEFAULTS])
+ GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_STRING_MODULE_INDICATOR_DEFAULTS],
+[
+ GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM])
+ GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY])
+ GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR])
+ GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY])
+ GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY])
+ GNULIB_STRCASE=0; AC_SUBST([GNULIB_STRCASE])
+ GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL])
+ GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP])
+ GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP])
+ GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN])
+ GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK])
+ GNULIB_STRSEP=0; AC_SUBST([GNULIB_STRSEP])
+ GNULIB_STRSTR=0; AC_SUBST([GNULIB_STRSTR])
+ GNULIB_STRCASESTR=0; AC_SUBST([GNULIB_STRCASESTR])
+ GNULIB_STRTOK_R=0; AC_SUBST([GNULIB_STRTOK_R])
+])
diff --git a/lgl/string_.h b/lgl/string_.h
index 617a51b9df..b99461a0b3 100644
--- a/lgl/string_.h
+++ b/lgl/string_.h
@@ -21,39 +21,95 @@
#include @ABSOLUTE_STRING_H@
+
+/* GL_LINK_WARNING("literal string") arranges to emit the literal string as
+ a linker warning on most glibc systems.
+ We use a linker warning rather than a preprocessor warning, because
+ #warning cannot be used inside macros. */
+#ifndef GL_LINK_WARNING
+ /* This works on platforms with GNU ld and ELF object format.
+ Testing __GLIBC__ is sufficient for asserting that GNU ld is in use.
+ Testing __ELF__ guarantees the ELF object format.
+ Testing __GNUC__ is necessary for the compound expression syntax. */
+# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__
+# define GL_LINK_WARNING(message) \
+ GL_LINK_WARNING1 (__FILE__, __LINE__, message)
+# define GL_LINK_WARNING1(file, line, message) \
+ GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */
+# define GL_LINK_WARNING2(file, line, message) \
+ GL_LINK_WARNING3 (file ":" #line ": " message)
+# define GL_LINK_WARNING3(message) \
+ ({ static const char warning[sizeof (message)] \
+ __attribute__ ((__unused__, \
+ __section__ (".gnu.warning"), \
+ __aligned__ (1))) \
+ = message "\n"; \
+ (void)0; \
+ })
+# else
+# define GL_LINK_WARNING(message) ((void) 0)
+# endif
+#endif
+
+
#ifdef __cplusplus
extern "C" {
#endif
/* Return the first occurrence of NEEDLE in HAYSTACK. */
-#if ! @HAVE_DECL_MEMMEM@
+#if @GNULIB_MEMMEM@
+# if ! @HAVE_DECL_MEMMEM@
extern void *memmem (void const *__haystack, size_t __haystack_len,
void const *__needle, size_t __needle_len);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef memmem
+# define memmem memmem_is_unportable__use_gnulib_module_memmem_for_portability
#endif
/* Copy N bytes of SRC to DEST, return pointer to bytes after the
last written byte. */
-#if ! @HAVE_MEMPCPY@
+#if @GNULIB_MEMPCPY@
+# if ! @HAVE_MEMPCPY@
extern void *mempcpy (void *restrict __dest, void const *restrict __src,
size_t __n);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mempcpy
+# define mempcpy mempcpy_is_unportable__use_gnulib_module_mempcpy_for_portability
#endif
/* Search backwards through a block for a byte (specified as an int). */
-#if ! @HAVE_DECL_MEMRCHR@
+#if @GNULIB_MEMRCHR@
+# if ! @HAVE_DECL_MEMRCHR@
extern void *memrchr (void const *, int, size_t);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef memrchr
+# define memrchr memrchr_is_unportable__use_gnulib_module_memrchr_for_portability
#endif
/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
-#if ! @HAVE_STPCPY@
+#if @GNULIB_STPCPY@
+# if ! @HAVE_STPCPY@
extern char *stpcpy (char *restrict __dst, char const *restrict __src);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef stpcpy
+# define stpcpy stpcpy_is_unportable__use_gnulib_module_stpcpy_for_portability
#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
+#if @GNULIB_STPNCPY@
+# if ! @HAVE_STPNCPY@
+# define stpncpy gnu_stpncpy
extern char *stpncpy (char *restrict __dst, char const *restrict __src,
size_t __n);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef stpncpy
+# define stpncpy stpncpy_is_unportable__use_gnulib_module_stpncpy_for_portability
#endif
/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
@@ -64,48 +120,88 @@ extern char *stpncpy (char *restrict __dst, char const *restrict __src,
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
+#if @GNULIB_STRCASE@
+# if @REPLACE_STRCASECMP@
+# define strcasecmp rpl_strcasecmp
extern int strcasecmp (char const *__s1, char const *__s2);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strcasecmp
+# define strcasecmp(a,b) \
+ (GL_LINK_WARNING ("strcasecmp is often incorrectly implemented for multibyte locales - use gnulib module 'strcase' for correct and portable internationalization"), \
+ strcasecmp (a, b))
#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@
+#if @GNULIB_STRCASE@
+# if ! @HAVE_DECL_STRNCASECMP@
extern int strncasecmp (char const *__s1, char const *__s2, size_t __n);
+# endif
+#endif
+#if defined GNULIB_POSIXCHECK
+# undef strncasecmp
+# define strncasecmp(a,b) \
+ (GL_LINK_WARNING ("strncasecmp cannot work correctly in multibyte locales - don't use it if you care about internationalization"), \
+ strncasecmp (a, b))
#endif
/* Find the first occurrence of C in S or the final NUL byte. */
-#if ! @HAVE_STRCHRNUL@
+#if @GNULIB_STRCHRNUL@
+# if ! @HAVE_STRCHRNUL@
extern char *strchrnul (char const *__s, int __c_in);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strchrnul
+# define strchrnul strchrnul_is_unportable__use_gnulib_module_strchrnul_for_portability
#endif
/* Duplicate S, returning an identical malloc'd string. */
-#if ! @HAVE_DECL_STRDUP@ && ! defined strdup
+#if @GNULIB_STRDUP@
+# if ! @HAVE_DECL_STRDUP@ && ! defined strdup
extern char *strdup (char const *__s);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strdup
+# define strdup strdup_is_unportable__use_gnulib_module_strdup_for_portability
#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@
+#if @GNULIB_STRNDUP@
+# if ! @HAVE_STRNDUP@
+# undef strndup
+# define strndup rpl_strndup
+# if ! @HAVE_DECL_STRNDUP@
extern char *strndup (char const *__string, size_t __n);
+# endif
# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strndup
+# define strndup strndup_is_unportable__use_gnulib_module_strndup_for_portability
#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@
+#if @GNULIB_STRNLEN@
+# if ! @HAVE_DECL_STRNLEN@
extern size_t strnlen (char const *__string, size_t __maxlen);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strnlen
+# define strnlen strnlen_is_unportable__use_gnulib_module_strnlen_for_portability
#endif
/* Find the first occurrence in S of any character in ACCEPT. */
-#if ! @HAVE_STRPBRK@
+#if @GNULIB_STRPBRK@
+# if ! @HAVE_STRPBRK@
extern char *strpbrk (char const *__s, char const *__accept);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strpbrk
+# define strpbrk strpbrk_is_unportable__use_gnulib_module_strpbrk_for_portability
#endif
/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
@@ -124,28 +220,47 @@ extern char *strpbrk (char const *__s, char const *__accept);
characters are ASCII characters < 0x30.
See also strtok_r(). */
-#if ! @HAVE_STRSEP@
+#if @GNULIB_STRSEP@
+# if ! @HAVE_STRSEP@
extern char *strsep (char **restrict __stringp, char const *restrict __delim);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strsep
+# define strsep strsep_is_unportable__use_gnulib_module_strsep_for_portability
#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
+#if @GNULIB_STRSTR@
+# if @REPLACE_STRSTR@
+# undef strstr
+# define strstr rpl_strstr
extern char *strstr (char const *__haystack, char const *__needle);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strstr
+# define strstr(a,b) \
+ (GL_LINK_WARNING ("strstr is often incorrectly implemented for multibyte locales - use gnulib module 'strstr' for correct and portable internationalization"), \
+ strstr (a, b))
#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
+#if @GNULIB_STRCASESTR@
+# if @REPLACE_STRCASESTR@
+# undef strcasestr
+# define strcasestr rpl_strcasestr
extern char *strcasestr (const char *haystack, const char *needle);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strcasestr
+# define strcasestr(a,b) \
+ (GL_LINK_WARNING ("strcasestr is often incorrectly implemented for multibyte locales - use gnulib module 'strcasestr' for correct and portable internationalization"), \
+ strcasestr (a, b))
#endif
/* Parse S into tokens separated by characters in DELIM.
@@ -170,9 +285,14 @@ extern char *strcasestr (const char *haystack, const char *needle);
characters are ASCII characters < 0x30.
See also strsep(). */
-#if ! @HAVE_DECL_STRTOK_R@
+#if @GNULIB_STRTOK_R@
+# if ! @HAVE_DECL_STRTOK_R@
extern char *strtok_r (char *restrict __s, char const *restrict __sep,
char **restrict __lasts);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strtok_r
+# define strtok_r strtok_r_is_unportable__use_gnulib_module_strtok_r_for_portability
#endif
#ifdef __cplusplus