summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2006-08-09 23:42:26 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2006-08-09 23:42:26 +0000
commit93f90065f31c35780e2dc3d6b7c987677d9bc14e (patch)
treeba198c539d289ba716e4de9f420e58a61e214a84 /lib
parentd24265f9659d21c8e89f1f21cf3b774c7c120afe (diff)
downloadcoreutils-93f90065f31c35780e2dc3d6b7c987677d9bc14e.tar.xz
Sync from gnulib.
Diffstat (limited to 'lib')
-rw-r--r--lib/ChangeLog10
-rw-r--r--lib/allocsa.h17
-rwxr-xr-xlib/config.charset44
-rw-r--r--lib/error.c113
-rw-r--r--lib/error.h4
-rw-r--r--lib/exitfail.c2
-rw-r--r--lib/full-write.c2
-rw-r--r--lib/getaddrinfo.c14
-rw-r--r--lib/getaddrinfo.h134
-rw-r--r--lib/gettext.h166
-rw-r--r--lib/localcharset.c81
-rw-r--r--lib/mbchar.h121
-rw-r--r--lib/mbswidth.c2
-rw-r--r--lib/mkstemp-safer.c6
-rw-r--r--lib/pipe-safer.c11
-rw-r--r--lib/printf-args.c29
-rw-r--r--lib/quote.c2
-rw-r--r--lib/readlink.c2
-rw-r--r--lib/regex_internal.h3
-rw-r--r--lib/setenv.c6
-rw-r--r--lib/stdint_.h4
-rw-r--r--lib/stdio--.h5
-rw-r--r--lib/stdio-safer.h3
-rw-r--r--lib/stpcpy.c5
-rw-r--r--lib/strcspn.c7
-rw-r--r--lib/strtoimax.c8
-rw-r--r--lib/vasprintf.h4
-rw-r--r--lib/version-etc.c6
-rw-r--r--lib/wcwidth.h9
29 files changed, 631 insertions, 189 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 2f5dd5c92..71fc71572 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,13 @@
+2006-08-09 Paul Eggert <eggert@cs.ucla.edu>
+
+ * allocsa.h, config.charset, error.c, error.h, exitfail.c, full-write.c:
+ * getaddrinfo.c, getaddrinfo.h, gettext.h, localcharset.c, mbchar.h:
+ * mbswidth.c, mkstemp-safer.c, pipe-safer.c, printf-args.c, quote.c:
+ * readlink.c, regex_internal.h, setenv.c, stdint_.h, stdio--.h:
+ * stdio-safer.h, stpcpy.c, strcspn.c, strtoimax.c, vasnprintf.h:
+ * version-etc.c, wcwidth.h:
+ Update from gnulib.
+
2006-08-09 Jim Meyering <jim@meyering.net>
* rand-isaac.c: Include <config.h>.
diff --git a/lib/allocsa.h b/lib/allocsa.h
index cb6893ad1..f8c0bc0bd 100644
--- a/lib/allocsa.h
+++ b/lib/allocsa.h
@@ -1,5 +1,5 @@
/* Safe automatic memory allocation.
- Copyright (C) 2003-2004 Free Software Foundation, Inc.
+ Copyright (C) 2003-2006 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
@@ -23,6 +23,12 @@
#include <stddef.h>
#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call
alloca(N); otherwise it returns NULL. It either returns N bytes of
memory allocated on the stack, that lasts until the function returns,
@@ -69,6 +75,11 @@ extern void freesa (void *p);
If this would be useful in your application. please speak up. */
+#ifdef __cplusplus
+}
+#endif
+
+
/* ------------------- Auxiliary, non-public definitions ------------------- */
/* Determine the alignment of a type at compile time. */
@@ -81,6 +92,10 @@ extern void freesa (void *p);
/* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof
values. */
# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
+#elif defined _AIX
+ /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof
+ values. */
+# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
#else
# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
#endif
diff --git a/lib/config.charset b/lib/config.charset
index 98294583d..148ea441f 100755
--- a/lib/config.charset
+++ b/lib/config.charset
@@ -1,7 +1,7 @@
#! /bin/sh
# Output a system dependent table of character encoding aliases.
#
-# Copyright (C) 2000-2004 Free Software Foundation, Inc.
+# Copyright (C) 2000-2004, 2006 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
@@ -30,21 +30,21 @@
# The current list of GNU canonical charset names is as follows.
#
# name MIME? used by which systems
-# ASCII, ANSI_X3.4-1968 glibc solaris freebsd darwin
-# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd darwin
-# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd darwin
+# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin
+# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd darwin
+# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd darwin
# ISO-8859-3 Y glibc solaris
-# ISO-8859-4 Y osf solaris freebsd darwin
-# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd darwin
+# ISO-8859-4 Y osf solaris freebsd netbsd darwin
+# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd darwin
# ISO-8859-6 Y glibc aix hpux solaris
-# ISO-8859-7 Y glibc aix hpux irix osf solaris darwin
+# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd darwin
# ISO-8859-8 Y glibc aix hpux osf solaris
# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin
-# ISO-8859-13 glibc darwin
+# ISO-8859-13 glibc netbsd darwin
# ISO-8859-14 glibc
# ISO-8859-15 glibc aix osf solaris freebsd darwin
-# KOI8-R Y glibc solaris freebsd darwin
-# KOI8-U Y glibc freebsd darwin
+# KOI8-R Y glibc solaris freebsd netbsd darwin
+# KOI8-U Y glibc freebsd netbsd darwin
# KOI8-T glibc
# CP437 dos
# CP775 dos
@@ -57,7 +57,7 @@
# CP862 dos
# CP864 dos
# CP865 dos
-# CP866 freebsd darwin dos
+# CP866 freebsd netbsd darwin dos
# CP869 dos
# CP874 woe32 dos
# CP922 aix
@@ -70,22 +70,22 @@
# CP1125 dos
# CP1129 aix
# CP1250 woe32
-# CP1251 glibc solaris darwin woe32
+# CP1251 glibc solaris netbsd darwin woe32
# CP1252 aix woe32
# CP1253 woe32
# CP1254 woe32
# CP1255 glibc woe32
# CP1256 woe32
# CP1257 woe32
-# GB2312 Y glibc aix hpux irix solaris freebsd darwin
-# EUC-JP Y glibc aix hpux irix osf solaris freebsd darwin
-# EUC-KR Y glibc aix hpux irix osf solaris freebsd darwin
-# EUC-TW glibc aix hpux irix osf solaris
-# BIG5 Y glibc aix hpux osf solaris freebsd darwin
+# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin
+# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin
+# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin
+# EUC-TW glibc aix hpux irix osf solaris netbsd
+# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin
# BIG5-HKSCS glibc solaris
# GBK glibc aix osf solaris woe32 dos
-# GB18030 glibc solaris
-# SHIFT_JIS Y hpux osf solaris freebsd darwin
+# GB18030 glibc solaris netbsd
+# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
# JOHAB glibc solaris woe32
# TIS-620 glibc aix hpux osf solaris
# VISCII Y glibc
@@ -99,7 +99,7 @@
# HP-KANA8 hpux
# DEC-KANJI osf
# DEC-HANYU osf
-# UTF-8 Y glibc aix hpux osf solaris darwin
+# UTF-8 Y glibc aix hpux osf solaris netbsd darwin
#
# Note: Names which are not marked as being a MIME name should not be used in
# Internet protocols for information interchange (mail, news, etc.).
@@ -387,6 +387,8 @@ case "$os" in
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-4 ISO-8859-4"
echo "ISO8859-5 ISO-8859-5"
+ echo "ISO8859-7 ISO-8859-7"
+ echo "ISO8859-13 ISO-8859-13"
echo "ISO8859-15 ISO-8859-15"
echo "eucCN GB2312"
echo "eucJP EUC-JP"
@@ -479,7 +481,7 @@ case "$os" in
echo "# If you find that the encoding given for your language and"
echo "# country is not the one your DOS machine actually uses, just"
echo "# correct it in this file, and send a mail to"
- echo "# Juan Manuel Guerrero <st001906@hrz1.hrz.tu-darmstadt.de>"
+ echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
echo "# and Bruno Haible <bruno@clisp.org>."
echo "#"
echo "C ASCII"
diff --git a/lib/error.c b/lib/error.c
index 45698be8d..34e836552 100644
--- a/lib/error.c
+++ b/lib/error.c
@@ -1,5 +1,5 @@
/* Error handler for noninteractive utilities
- Copyright (C) 1990-1998, 2000-2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1990-1998, 2000-2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
@@ -34,6 +34,9 @@
#endif
#ifdef _LIBC
+# include <libintl.h>
+# include <stdbool.h>
+# include <stdint.h>
# include <wchar.h>
# define mbsrtowcs __mbsrtowcs
#endif
@@ -59,6 +62,7 @@ unsigned int error_message_count;
# define program_name program_invocation_name
# include <errno.h>
+# include <limits.h>
# include <libio/libioP.h>
/* In GNU libc we want do not want to use the common name `error' directly.
@@ -122,14 +126,10 @@ print_errno_message (int errnum)
#endif
#if _LIBC
- if (_IO_fwide (stderr, 0) > 0)
- {
- __fwprintf (stderr, L": %s", s);
- return;
- }
-#endif
-
+ __fxprintf (NULL, ": %s", s);
+#else
fprintf (stderr, ": %s", s);
+#endif
}
static void
@@ -140,26 +140,65 @@ error_tail (int status, int errnum, const char *message, va_list args)
{
# define ALLOCA_LIMIT 2000
size_t len = strlen (message) + 1;
- const wchar_t *wmessage = L"out of memory";
- wchar_t *wbuf = (len < ALLOCA_LIMIT
- ? alloca (len * sizeof *wbuf)
- : len <= SIZE_MAX / sizeof *wbuf
- ? malloc (len * sizeof *wbuf)
- : NULL);
-
- if (wbuf)
+ wchar_t *wmessage = NULL;
+ mbstate_t st;
+ size_t res;
+ const char *tmp;
+ bool use_malloc = false;
+
+ while (1)
{
- size_t res;
- mbstate_t st;
- const char *tmp = message;
+ if (__libc_use_alloca (len * sizeof (wchar_t)))
+ wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
+ else
+ {
+ if (!use_malloc)
+ wmessage = NULL;
+
+ wchar_t *p = (wchar_t *) realloc (wmessage,
+ len * sizeof (wchar_t));
+ if (p == NULL)
+ {
+ free (wmessage);
+ fputws_unlocked (L"out of memory\n", stderr);
+ return;
+ }
+ wmessage = p;
+ use_malloc = true;
+ }
+
memset (&st, '\0', sizeof (st));
- res = mbsrtowcs (wbuf, &tmp, len, &st);
- wmessage = res == (size_t) -1 ? L"???" : wbuf;
+ tmp = message;
+
+ res = mbsrtowcs (wmessage, &tmp, len, &st);
+ if (res != len)
+ break;
+
+ if (__builtin_expect (len >= SIZE_MAX / 2, 0))
+ {
+ /* This really should not happen if everything is fine. */
+ res = (size_t) -1;
+ break;
+ }
+
+ len *= 2;
+ }
+
+ if (res == (size_t) -1)
+ {
+ /* The string cannot be converted. */
+ if (use_malloc)
+ {
+ free (wmessage);
+ use_malloc = false;
+ }
+ wmessage = (wchar_t *) L"???";
}
__vfwprintf (stderr, wmessage, args);
- if (! (len < ALLOCA_LIMIT))
- free (wbuf);
+
+ if (use_malloc)
+ free (wmessage);
}
else
#endif
@@ -170,11 +209,10 @@ error_tail (int status, int errnum, const char *message, va_list args)
if (errnum)
print_errno_message (errnum);
#if _LIBC
- if (_IO_fwide (stderr, 0) > 0)
- putwc (L'\n', stderr);
- else
+ __fxprintf (NULL, "\n");
+#else
+ putc ('\n', stderr);
#endif
- putc ('\n', stderr);
fflush (stderr);
if (status)
exit (status);
@@ -207,11 +245,10 @@ error (int status, int errnum, const char *message, ...)
else
{
#if _LIBC
- if (_IO_fwide (stderr, 0) > 0)
- __fwprintf (stderr, L"%s: ", program_name);
- else
+ __fxprintf (NULL, "%s: ", program_name);
+#else
+ fprintf (stderr, "%s: ", program_name);
#endif
- fprintf (stderr, "%s: ", program_name);
}
va_start (args, message);
@@ -267,21 +304,19 @@ error_at_line (int status, int errnum, const char *file_name,
else
{
#if _LIBC
- if (_IO_fwide (stderr, 0) > 0)
- __fwprintf (stderr, L"%s: ", program_name);
- else
+ __fxprintf (NULL, "%s:", program_name);
+#else
+ fprintf (stderr, "%s:", program_name);
#endif
- fprintf (stderr, "%s:", program_name);
}
if (file_name != NULL)
{
#if _LIBC
- if (_IO_fwide (stderr, 0) > 0)
- __fwprintf (stderr, L"%s:%d: ", file_name, line_number);
- else
+ __fxprintf (NULL, "%s:%d: ", file_name, line_number);
+#else
+ fprintf (stderr, "%s:%d: ", file_name, line_number);
#endif
- fprintf (stderr, "%s:%d: ", file_name, line_number);
}
va_start (args, message);
diff --git a/lib/error.h b/lib/error.h
index e5220a2f1..5a5f24765 100644
--- a/lib/error.h
+++ b/lib/error.h
@@ -1,5 +1,5 @@
/* Declaration for error-reporting function
- Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,7 @@
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
diff --git a/lib/exitfail.c b/lib/exitfail.c
index 27d38c32a..24df22851 100644
--- a/lib/exitfail.c
+++ b/lib/exitfail.c
@@ -1,6 +1,6 @@
/* Failure exit status
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2005 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
diff --git a/lib/full-write.c b/lib/full-write.c
index 106f3c7e5..c4624e5dc 100644
--- a/lib/full-write.c
+++ b/lib/full-write.c
@@ -1,7 +1,7 @@
/* An interface to read and write that retries (if necessary) until complete.
Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- 2004 Free Software Foundation, Inc.
+ 2004, 2005 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
diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c
index e6bad1103..9003abf60 100644
--- a/lib/getaddrinfo.c
+++ b/lib/getaddrinfo.c
@@ -140,7 +140,7 @@ getaddrinfo (const char *restrict nodename,
return getaddrinfo_ptr (nodename, servname, hints, res);
#endif
- if (hints && (hints->ai_flags & ~AI_CANONNAME))
+ if (hints && (hints->ai_flags & ~(AI_CANONNAME|AI_PASSIVE)))
/* FIXME: Support more flags. */
return EAI_BADFLAGS;
@@ -153,8 +153,16 @@ getaddrinfo (const char *restrict nodename,
return EAI_SOCKTYPE; /* FIXME: Better return code? */
if (!nodename)
- /* FIXME: Support server bind mode. */
- return EAI_NONAME;
+ {
+ if (!(hints->ai_flags & AI_PASSIVE))
+ return EAI_NONAME;
+
+#ifdef HAVE_IPV6
+ nodename = (hint->ai_family == AF_INET6) ? "::" : "0.0.0.0";
+#else
+ nodename = "0.0.0.0";
+#endif
+ }
if (servname)
{
diff --git a/lib/getaddrinfo.h b/lib/getaddrinfo.h
index d87485ef8..b4ef242cf 100644
--- a/lib/getaddrinfo.h
+++ b/lib/getaddrinfo.h
@@ -1,5 +1,6 @@
/* Get address information.
- Copyright (C) 1996-2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1996-2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
Contributed by Simon Josefsson <simon@josefsson.org>.
This program is free software; you can redistribute it and/or modify
@@ -17,20 +18,20 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef GETADDRINFO_H
-# define GETADDRINFO_H
+#define GETADDRINFO_H
/* sys/socket.h in i386-unknown-freebsd4.10 and
powerpc-apple-darwin5.5 require sys/types.h, so include it first.
Then we'll also get 'socklen_t' and 'struct sockaddr' which are
used below. */
-# include <sys/types.h>
+#include <sys/types.h>
/* Get all getaddrinfo related declarations, if available. */
-# include <sys/socket.h>
+#include <sys/socket.h>
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
-# ifndef HAVE_STRUCT_ADDRINFO
+#ifndef HAVE_STRUCT_ADDRINFO
/* Structure to contain information about address of a service provider. */
struct addrinfo
@@ -44,69 +45,70 @@ struct addrinfo
char *ai_canonname; /* Canonical name for service location. */
struct addrinfo *ai_next; /* Pointer to next in list. */
};
-# endif
+#endif
/* Possible values for `ai_flags' field in `addrinfo' structure. */
-# ifndef AI_PASSIVE
-# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
-# endif
-# ifndef AI_CANONNAME
-# define AI_CANONNAME 0x0002 /* Request for canonical name. */
-# endif
-# ifndef AI_NUMERICHOST
-# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
-# endif
-# ifndef AI_V4MAPPED
-# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
-# endif
-# ifndef AI_ALL
-# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
-# endif
-# ifndef AI_ADDRCONFIG
-# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
- returned address type.. */
+#ifndef AI_PASSIVE
+# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
+#endif
+#ifndef AI_CANONNAME
+# define AI_CANONNAME 0x0002 /* Request for canonical name. */
#endif
#ifndef AI_NUMERICSERV
-# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
-# endif
+# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
+#endif
+
+#if 0
+/* The commented out definitions below are not yet implemented in the
+ GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact,
+ cause conflicts on systems with a getaddrinfo() function which does not
+ define them.
+
+ If they are restored, be sure to protect the definitions with #ifndef. */
+#define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
+#define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
+#define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
+#define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
+ returned address type.. */
+#endif /* 0 */
/* Error values for `getaddrinfo' function. */
-# ifndef EAI_BADFLAGS
-# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
-# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
-# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
-# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
-# define EAI_NODATA -5 /* No address associated with NAME. */
-# define EAI_FAMILY -6 /* `ai_family' not supported. */
-# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
-# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
-# define EAI_MEMORY -10 /* Memory allocation failure. */
+#ifndef EAI_BADFLAGS
+# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
+# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
+# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
+# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
+# define EAI_NODATA -5 /* No address associated with NAME. */
+# define EAI_FAMILY -6 /* `ai_family' not supported. */
+# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
+# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
+# define EAI_MEMORY -10 /* Memory allocation failure. */
#endif
#ifndef EAI_OVERFLOW
/* Not defined on mingw32. */
-# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
+# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
#endif
-# ifndef EAI_ADDRFAMILY
+#ifndef EAI_ADDRFAMILY
/* Not defined on mingw32. */
-# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
-# endif
-# ifndef EAI_SYSTEM
+# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
+#endif
+#ifndef EAI_SYSTEM
/* Not defined on mingw32. */
-# define EAI_SYSTEM -11 /* System error returned in `errno'. */
-# endif
+# define EAI_SYSTEM -11 /* System error returned in `errno'. */
+#endif
-# ifdef __USE_GNU
-# ifndef EAI_INPROGRESS
-# define EAI_INPROGRESS -100 /* Processing request in progress. */
-# define EAI_CANCELED -101 /* Request canceled. */
-# define EAI_NOTCANCELED -102 /* Request not canceled. */
-# define EAI_ALLDONE -103 /* All requests done. */
-# define EAI_INTR -104 /* Interrupted by a signal. */
-# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
-# endif
+#ifdef __USE_GNU
+# ifndef EAI_INPROGRESS
+# define EAI_INPROGRESS -100 /* Processing request in progress. */
+# define EAI_CANCELED -101 /* Request canceled. */
+# define EAI_NOTCANCELED -102 /* Request not canceled. */
+# define EAI_ALLDONE -103 /* All requests done. */
+# define EAI_INTR -104 /* Interrupted by a signal. */
+# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
# endif
+#endif
-# if !HAVE_DECL_GETADDRINFO
+#if !HAVE_DECL_GETADDRINFO
/* Translate name of a service location and/or a service name to set of
socket addresses.
For more details, see the POSIX:2001 specification
@@ -115,23 +117,23 @@ extern int getaddrinfo (const char *restrict nodename,
const char *restrict servname,
const struct addrinfo *restrict hints,
struct addrinfo **restrict res);
-# endif
+#endif
-# if !HAVE_DECL_FREEADDRINFO
+#if !HAVE_DECL_FREEADDRINFO
/* Free `addrinfo' structure AI including associated storage.
For more details, see the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
extern void freeaddrinfo (struct addrinfo *ai);
-# endif
+#endif
-# if !HAVE_DECL_GAI_STRERROR
+#if !HAVE_DECL_GAI_STRERROR
/* Convert error return from getaddrinfo() to a string.
For more details, see the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/gai_strerror.html>. */
extern const char *gai_strerror (int ecode);
-# endif
+#endif
-# if !HAVE_DECL_GETNAMEINFO
+#if !HAVE_DECL_GETNAMEINFO
/* Convert socket address to printable node and service names.
For more details, see the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/getnameinfo.html>. */
@@ -140,14 +142,14 @@ extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
char *restrict service, socklen_t servicelen,
int flags);
-# endif
+#endif
/* Possible flags for getnameinfo. */
-# ifndef NI_NUMERICHOST
-# define NI_NUMERICHOST 1
-# endif
-# ifndef NI_NUMERICSERV
-# define NI_NUMERICSERV 2
-# endif
+#ifndef NI_NUMERICHOST
+# define NI_NUMERICHOST 1
+#endif
+#ifndef NI_NUMERICSERV
+# define NI_NUMERICSERV 2
+#endif
#endif /* GETADDRINFO_H */
diff --git a/lib/gettext.h b/lib/gettext.h
index 285cb314c..deeaf7931 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -1,5 +1,5 @@
/* Convenience header for conditional use of GNU <libintl.h>.
- Copyright (C) 1995-1998, 2000-2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006 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
@@ -75,4 +75,168 @@
initializer for static 'char[]' or 'const char[]' variables. */
#define gettext_noop(String) String
+/* The separator between msgctxt and msgid in a .mo file. */
+#define GETTEXT_CONTEXT_GLUE "\004"
+
+/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
+ MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
+ short and rarely need to change.
+ The letter 'p' stands for 'particular' or 'special'. */
+#define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#define dpgettext(Domainname, Msgctxt, Msgid) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
+#define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+pgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ int category)
+{
+ const char *translation = dcgettext (domain, msg_ctxt_id, category);
+ if (translation == msg_ctxt_id)
+ return msgid;
+ else
+ return translation;
+}
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+npgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ const char *translation =
+ dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+ if (translation == msg_ctxt_id || translation == msgid_plural)
+ return (n == 1 ? msgid : msgid_plural);
+ else
+ return translation;
+}
+
+/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
+ can be arbitrary expressions. But for string literals these macros are
+ less efficient than those above. */
+
+#include <string.h>
+
+#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
+ (__GNUC__ >= 3 || defined __cplusplus)
+
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+#include <stdlib.h>
+#endif
+
+#define pgettext_expr(Msgctxt, Msgid) \
+ dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+ dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcgettext (domain, msg_ctxt_id, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (translation != msg_ctxt_id)
+ return translation;
+ }
+ return msgid;
+}
+
+#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcnpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (!(translation == msg_ctxt_id || translation == msgid_plural))
+ return translation;
+ }
+ return (n == 1 ? msgid : msgid_plural);
+}
+
#endif /* _LIBGETTEXT_H */
diff --git a/lib/localcharset.c b/lib/localcharset.c
index d03ab79d0..cd44ca658 100644
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
@@ -25,23 +25,13 @@
/* Specification. */
#include "localcharset.h"
-#if HAVE_STDDEF_H
-# include <stddef.h>
-#endif
-
+#include <stddef.h>
#include <stdio.h>
-#if HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+#include <string.h>
+#include <stdlib.h>
#if defined _WIN32 || defined __WIN32__
-# undef WIN32 /* avoid warning on mingw32 */
-# define WIN32
+# define WIN32_NATIVE
#endif
#if defined __EMX__
@@ -49,7 +39,7 @@
# define OS2
#endif
-#if !defined WIN32
+#if !defined WIN32_NATIVE
# if HAVE_LANGINFO_CODESET
# include <langinfo.h>
# else
@@ -57,7 +47,11 @@
# include <locale.h>
# endif
# endif
-#elif defined WIN32
+# ifdef __CYGWIN__
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# endif
+#elif defined WIN32_NATIVE
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
@@ -113,7 +107,7 @@ get_charset_aliases (void)
cp = charset_aliases;
if (cp == NULL)
{
-#if !(defined VMS || defined WIN32)
+#if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
FILE *fp;
const char *dir;
const char *base = "charset.alias";
@@ -239,7 +233,7 @@ get_charset_aliases (void)
"DECKOREAN" "\0" "EUC-KR" "\0";
# endif
-# if defined WIN32
+# if defined WIN32_NATIVE || defined __CYGWIN__
/* To avoid the troubles of installing a separate file in the same
directory as the DLL and of retrieving the DLL's directory at
runtime, simply inline the aliases here. */
@@ -291,13 +285,60 @@ locale_charset (void)
const char *codeset;
const char *aliases;
-#if !(defined WIN32 || defined OS2)
+#if !(defined WIN32_NATIVE || defined OS2)
# if HAVE_LANGINFO_CODESET
/* Most systems support nl_langinfo (CODESET) nowadays. */
codeset = nl_langinfo (CODESET);
+# ifdef __CYGWIN__
+ /* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always
+ returns "US-ASCII". As long as this is not fixed, return the suffix
+ of the locale name from the environment variables (if present) or
+ the codepage as a number. */
+ if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
+ {
+ const char *locale;
+ static char buf[2 + 10 + 1];
+
+ locale = getenv ("LC_ALL");
+ if (locale == NULL || locale[0] == '\0')
+ {
+ locale = getenv ("LC_CTYPE");
+ if (locale == NULL || locale[0] == '\0')
+ locale = getenv ("LANG");
+ }
+ if (locale != NULL && locale[0] != '\0')
+ {
+ /* If the locale name contains an encoding after the dot, return
+ it. */
+ const char *dot = strchr (locale, '.');
+
+ if (dot != NULL)
+ {
+ const char *modifier;
+
+ dot++;
+ /* Look for the possible @... trailer and remove it, if any. */
+ modifier = strchr (dot, '@');
+ if (modifier == NULL)
+ return dot;
+ if (modifier - dot < sizeof (buf))
+ {
+ memcpy (buf, dot, modifier - dot);
+ buf [modifier - dot] = '\0';
+ return buf;
+ }
+ }
+ }
+
+ /* Woe32 has a function returning the locale's codepage as a number. */
+ sprintf (buf, "CP%u", GetACP ());
+ codeset = buf;
+ }
+# endif
+
# else
/* On old systems which lack it, use setlocale or getenv. */
@@ -328,7 +369,7 @@ locale_charset (void)
# endif
-#elif defined WIN32
+#elif defined WIN32_NATIVE
static char buf[2 + 10 + 1];
diff --git a/lib/mbchar.h b/lib/mbchar.h
index 738efd948..52b107578 100644
--- a/lib/mbchar.h
+++ b/lib/mbchar.h
@@ -157,6 +157,127 @@
#include <wchar.h>
#include <wctype.h>
+/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
+ Assume all 12 functions are implemented the same way, or not at all. */
+#if !defined iswalnum && !HAVE_ISWCNTRL
+static inline int
+iswalnum (wint_t wc)
+{
+ return (wc >= 0 && wc < 128
+ ? (wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')
+ : 0);
+}
+# define iswalnum iswalnum
+#endif
+#if !defined iswalpha && !HAVE_ISWCNTRL
+static inline int
+iswalpha (wint_t wc)
+{
+ return (wc >= 0 && wc < 128
+ ? (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'
+ : 0);
+}
+# define iswalpha iswalpha
+#endif
+#if !defined iswblank && !HAVE_ISWCNTRL
+static inline int
+iswblank (wint_t wc)
+{
+ return (wc >= 0 && wc < 128
+ ? wc == ' ' || wc == '\t'
+ : 0);
+}
+# define iswblank iswblank
+#endif
+#if !defined iswcntrl && !HAVE_ISWCNTRL
+static inline int
+iswcntrl (wint_t wc)
+{
+ return (wc >= 0 && wc < 128
+ ? (wc & ~0x1f) == 0 || wc == 0x7f
+ : 0);
+}
+# define iswcntrl iswcntrl
+#endif
+#if !defined iswdigit && !HAVE_ISWCNTRL
+static inline int
+iswdigit (wint_t wc)
+{
+ return (wc >= '0' && wc <= '9');
+}
+# define iswdigit iswdigit
+#endif
+#if !defined iswgraph && !HAVE_ISWCNTRL
+static inline int
+iswgraph (wint_t wc)
+{
+ return (wc >= 0 && wc < 128
+ ? wc >= '!' && wc <= '~'
+ : 1);
+}
+# define iswgraph iswgraph
+#endif
+#if !defined iswlower && !HAVE_ISWCNTRL
+static inline int
+iswlower (wint_t wc)
+{
+ return (wc >= 0 && wc < 128
+ ? wc >= 'a' && wc <= 'z'
+ : 0);
+}
+# define iswlower iswlower
+#endif
+#if !defined iswprint && !HAVE_ISWCNTRL
+static inline int
+iswprint (wint_t wc)
+{
+ return (wc >= 0 && wc < 128
+ ? wc >= ' ' && wc <= '~'
+ : 1);
+}
+# define iswprint iswprint
+#endif
+#if !defined iswpunct && !HAVE_ISWCNTRL
+static inline int
+iswpunct (wint_t wc)
+{
+ return (wc >= 0 && wc < 128
+ ? wc >= '!' && wc <= '~'
+ && !((wc >= '0' && wc <= '9')
+ || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))
+ : 1);
+}
+# define iswpunct iswpunct
+#endif
+#if !defined iswspace && !HAVE_ISWCNTRL
+static inline int
+iswspace (wint_t wc)
+{
+ return (wc >= 0 && wc < 128
+ ? wc == ' ' || wc == '\t'
+ || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'
+ : 0);
+}
+# define iswspace iswspace
+#endif
+#if !defined iswupper && !HAVE_ISWCNTRL
+static inline int
+iswupper (wint_t wc)
+{
+ return (wc >= 0 && wc < 128
+ ? wc >= 'A' && wc <= 'Z'
+ : 0);
+}
+# define iswupper iswupper
+#endif
+#if !defined iswxdigit && !HAVE_ISWCNTRL
+static inline int
+iswxdigit (wint_t wc)
+{
+ return (wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F');
+}
+# define iswxdigit iswxdigit
+#endif
#include "wcwidth.h"
diff --git a/lib/mbswidth.c b/lib/mbswidth.c
index 48da6639d..072695172 100644
--- a/lib/mbswidth.c
+++ b/lib/mbswidth.c
@@ -51,7 +51,7 @@
# include <wctype.h>
#endif
#if !defined iswcntrl && !HAVE_ISWCNTRL
-# define iswcntrl(wc) 0
+# define iswcntrl(wc) (((wc) & ~0x1f) == 0 || (wc) == 0x7f)
#endif
#ifndef mbsinit
diff --git a/lib/mkstemp-safer.c b/lib/mkstemp-safer.c
index 5ae3413f0..315385da0 100644
--- a/lib/mkstemp-safer.c
+++ b/lib/mkstemp-safer.c
@@ -1,6 +1,6 @@
/* Invoke mkstemp, but avoid some glitches.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 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
@@ -27,6 +27,10 @@
#include <stdlib.h>
#include "unistd-safer.h"
+#if ! HAVE_MKSTEMP
+int mkstemp (char *);
+#endif
+
/* Like mkstemp, but do not return STDIN_FILENO, STDOUT_FILENO, or
STDERR_FILENO. */
diff --git a/lib/pipe-safer.c b/lib/pipe-safer.c
index fb02d7217..646cd5dab 100644
--- a/lib/pipe-safer.c
+++ b/lib/pipe-safer.c
@@ -1,5 +1,5 @@
/* Invoke pipe, but avoid some glitches.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 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
@@ -24,13 +24,16 @@
#include "unistd-safer.h"
#include <unistd.h>
+#include <errno.h>
/* Like pipe, but ensure that neither of the file descriptors is
- STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO. */
+ STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO. Fail with ENOSYS on
+ platforms that lack pipe. */
int
pipe_safer (int fd[2])
{
+#if HAVE_FUNC_PIPE
int fail = pipe (fd);
if (fail)
return fail;
@@ -47,4 +50,8 @@ pipe_safer (int fd[2])
}
return 0;
+#else /* ! HAVE_FUNC_PIPE */
+ errno = ENOSYS;
+ return -1;
+#endif
}
diff --git a/lib/printf-args.c b/lib/printf-args.c
index 0ed1acbb8..761345622 100644
--- a/lib/printf-args.c
+++ b/lib/printf-args.c
@@ -1,5 +1,5 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2003, 2005-2006 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
@@ -79,15 +79,40 @@ printf_fetchargs (va_list args, arguments *a)
break;
#ifdef HAVE_WINT_T
case TYPE_WIDE_CHAR:
- ap->a.a_wide_char = va_arg (args, wint_t);
+ /* 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,
+ where wint_t is 'unsigned short'. */
+ ap->a.a_wide_char =
+ (sizeof (wint_t) < sizeof (int)
+ ? va_arg (args, int)
+ : va_arg (args, wint_t));
break;
#endif
case TYPE_STRING:
ap->a.a_string = va_arg (args, const char *);
+ /* A null pointer is an invalid argument for "%s", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_string == NULL)
+ ap->a.a_string = "(NULL)";
break;
#ifdef 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
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_wide_string == NULL)
+ {
+ static const wchar_t wide_null_string[] =
+ {
+ (wchar_t)'(',
+ (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
+ (wchar_t)')',
+ (wchar_t)0
+ };
+ ap->a.a_wide_string = wide_null_string;
+ }
break;
#endif
case TYPE_POINTER:
diff --git a/lib/quote.c b/lib/quote.c
index 16cc939c1..70f1d1d75 100644
--- a/lib/quote.c
+++ b/lib/quote.c
@@ -1,5 +1,5 @@
/* quote.c - quote arguments for output
- Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005 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
diff --git a/lib/readlink.c b/lib/readlink.c
index 3196aecb0..875cc9736 100644
--- a/lib/readlink.c
+++ b/lib/readlink.c
@@ -1,5 +1,5 @@
/* Stub for readlink().
- Copyright (C) 2003-2004 Free Software Foundation, Inc.
+ Copyright (C) 2003-2005 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
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 993c9923e..06f89a47f 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -49,7 +49,6 @@
#if defined _LIBC
# include <bits/libc-lock.h>
#else
-# define __libc_lock_define(CLASS,NAME)
# define __libc_lock_init(NAME) do { } while (0)
# define __libc_lock_lock(NAME) do { } while (0)
# define __libc_lock_unlock(NAME) do { } while (0)
@@ -711,7 +710,9 @@ struct re_dfa_t
#ifdef DEBUG
char* re_str;
#endif
+#ifdef _LIBC
__libc_lock_define (, lock)
+#endif
};
#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
diff --git a/lib/setenv.c b/lib/setenv.c
index 1cbe1a25b..335d1d2f9 100644
--- a/lib/setenv.c
+++ b/lib/setenv.c
@@ -13,7 +13,7 @@
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. */
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -27,7 +27,9 @@
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+#if _LIBC || HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#if !_LIBC
# include "allocsa.h"
diff --git a/lib/stdint_.h b/lib/stdint_.h
index adab4d7c2..44eca933c 100644
--- a/lib/stdint_.h
+++ b/lib/stdint_.h
@@ -394,8 +394,12 @@
#define WINT_MAX \
_STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
+#endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */
+
/* 7.18.4. Macros for integer constants */
+#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
+
/* 7.18.4.1. Macros for minimum-width integer constants */
/* According to ISO C 99 Technical Corrigendum 1 */
diff --git a/lib/stdio--.h b/lib/stdio--.h
index b2765fd52..2385e626f 100644
--- a/lib/stdio--.h
+++ b/lib/stdio--.h
@@ -1,6 +1,6 @@
/* Like stdio.h, but redefine some names to avoid glitches.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 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
@@ -23,3 +23,6 @@
#undef fopen
#define fopen fopen_safer
+
+#undef tmpfile
+#define tmpfile tmpfile_safer
diff --git a/lib/stdio-safer.h b/lib/stdio-safer.h
index 0b9a9ab80..8329a1a09 100644
--- a/lib/stdio-safer.h
+++ b/lib/stdio-safer.h
@@ -1,6 +1,6 @@
/* Invoke stdio functions, but avoid some glitches.
- Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2006 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
@@ -21,3 +21,4 @@
#include <stdio.h>
FILE *fopen_safer (char const *, char const *);
+FILE *tmpfile_safer (void);
diff --git a/lib/stpcpy.c b/lib/stpcpy.c
index acda21a26..bb667a05e 100644
--- a/lib/stpcpy.c
+++ b/lib/stpcpy.c
@@ -15,9 +15,8 @@
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. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/lib/strcspn.c b/lib/strcspn.c
index 9fbc5de49..46d7d36ca 100644
--- a/lib/strcspn.c
+++ b/lib/strcspn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1996-1997, 2002-2003 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1994, 1996-1997, 2002-2003, 2005 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
@@ -14,9 +14,8 @@
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. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/lib/strtoimax.c b/lib/strtoimax.c
index a15b84af3..098cfa966 100644
--- a/lib/strtoimax.c
+++ b/lib/strtoimax.c
@@ -23,12 +23,8 @@
# include <config.h>
#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
+/* Verify interface. */
+#include <inttypes.h>
#include <stdlib.h>
diff --git a/lib/vasprintf.h b/lib/vasprintf.h
index d02f15451..ab5515ce7 100644
--- a/lib/vasprintf.h
+++ b/lib/vasprintf.h
@@ -11,8 +11,8 @@
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,
+ 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 _VASPRINTF_H
diff --git a/lib/version-etc.c b/lib/version-etc.c
index cb9e4c2f0..7887c26e2 100644
--- a/lib/version-etc.c
+++ b/lib/version-etc.c
@@ -50,11 +50,7 @@ version_etc_va (FILE *stream,
{
va_list tmp_authors;
-#ifdef __va_copy
- __va_copy (tmp_authors, authors);
-#else
- tmp_authors = authors;
-#endif
+ va_copy (tmp_authors, authors);
n_authors = 0;
while (va_arg (tmp_authors, const char *) != NULL)
diff --git a/lib/wcwidth.h b/lib/wcwidth.h
index 9af75e0a7..37b83cb82 100644
--- a/lib/wcwidth.h
+++ b/lib/wcwidth.h
@@ -36,7 +36,14 @@
# include <wctype.h>
# endif
# if !defined iswprint && !HAVE_ISWPRINT
-# define iswprint(wc) 1
+static inline int
+iswprint (wint_t wc)
+{
+ return (wc >= 0 && wc < 128
+ ? wc >= ' ' && wc <= '~'
+ : 1);
+}
+# define iswprint iswprint
# endif
# ifndef HAVE_DECL_WCWIDTH