mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-21 11:16:16 +02:00
Sync from gnulib.
This commit is contained in:
@@ -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>.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
111
lib/error.c
111
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);
|
||||
wchar_t *wmessage = NULL;
|
||||
mbstate_t st;
|
||||
size_t res;
|
||||
const char *tmp;
|
||||
bool use_malloc = false;
|
||||
|
||||
if (wbuf)
|
||||
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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 */
|
||||
|
||||
166
lib/gettext.h
166
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 */
|
||||
|
||||
@@ -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];
|
||||
|
||||
|
||||
121
lib/mbchar.h
121
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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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. */
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user