Commit 3e718271 3e718271bbdce86739f4b40655d57611d858bc59 by Sergey Poznyakoff

Added to the repository by gnulib-sync

1 parent 94a921a7
#serial 8
dnl From Jim Meyering.
dnl
dnl Check whether struct dirent has a member named d_type.
dnl
# Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
# Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
[AC_REQUIRE([AC_HEADER_DIRENT])dnl
AC_CACHE_CHECK([for d_type member in directory struct],
jm_cv_struct_dirent_d_type,
[AC_TRY_LINK(dnl
[
#include <sys/types.h>
#ifdef HAVE_DIRENT_H
# include <dirent.h>
#else /* not HAVE_DIRENT_H */
# define dirent direct
# ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif /* HAVE_SYS_NDIR_H */
# ifdef HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif /* HAVE_SYS_DIR_H */
# ifdef HAVE_NDIR_H
# include <ndir.h>
# endif /* HAVE_NDIR_H */
#endif /* HAVE_DIRENT_H */
],
[struct dirent dp; dp.d_type = 0;],
jm_cv_struct_dirent_d_type=yes,
jm_cv_struct_dirent_d_type=no)
]
)
if test $jm_cv_struct_dirent_d_type = yes; then
AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE, 1,
[Define if there is a member named d_type in the struct describing
directory headers.])
fi
]
)
#serial 1
# Copyright (C) 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
dnl From Derek Price
dnl
dnl Provide getlogin_r when the system lacks it.
dnl
AC_DEFUN([gl_GETLOGIN_R_SUBSTITUTE],
[
gl_PREREQ_GETLOGIN_R
MU_LIBSOURCE([getlogin_r.h])
MU_LIBOBJ([getlogin_r])
])
AC_DEFUN([gl_GETLOGIN_R],
[
MU_REPLACE_FUNCS([getlogin_r])
if test $ac_cv_func_getlogin_r = no; then
gl_GETLOGIN_R_SUBSTITUTE
fi
])
AC_DEFUN([gl_PREREQ_GETLOGIN_R],
[
AC_CHECK_HEADERS_ONCE([unistd.h])
AC_CHECK_DECLS_ONCE([getlogin getlogin_r])
])
# glob.m4 serial 3
dnl Copyright (C) 2005 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.
# The glob module assumes you want GNU glob, with glob_pattern_p etc,
# rather than vanilla POSIX glob. This means your your code should
# always include <glob.h> for the glob prototypes.
AC_DEFUN([gl_GLOB_SUBSTITUTE],
[
gl_PREREQ_GLOB
GLOB_H=glob.h
MU_LIBSOURCES([glob.c, glob_.h, glob-libc.h])
MU_LIBOBJ([glob])
AC_SUBST([GLOB_H])
])
AC_DEFUN([gl_GLOB],
[ GLOB_H=
AC_CHECK_HEADERS([glob.h], [], [GLOB_H=glob.h])
if test -z "$GLOB_H"; then
AC_CACHE_CHECK([for GNU glob interface version 1],
[gl_cv_gnu_glob_interface_version_1],
[ AC_COMPILE_IFELSE(
[[#include <gnu-versions.h>
char a[_GNU_GLOB_INTERFACE_VERSION == 1 ? 1 : -1];]],
[gl_cv_gnu_glob_interface_version_1=yes],
[gl_cv_gnu_glob_interface_version_1=no])])
if test "$gl_cv_gnu_glob_interface_version_1" = "no"; then
GLOB_H=glob.h
fi
fi
if test -z "$GLOB_H"; then
AC_CACHE_CHECK([whether glob lists broken symlinks],
[gl_cv_glob_lists_symlinks],
[ if ln -s conf-doesntexist conf$$-globtest 2>/dev/null; then
gl_cv_glob_lists_symlinks=maybe
else
# If we can't make a symlink, then we cannot test this issue. Be
# pessimistic about this.
gl_cv_glob_lists_symlinks=no
fi
if test $gl_cv_glob_lists_symlinks = maybe; then
AC_RUN_IFELSE(
AC_LANG_PROGRAM(
[[#include <stddef.h>
#include <glob.h>]],
[[glob_t found;
if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1;]]),
[gl_cv_glob_lists_symlinks=yes],
[gl_cv_glob_lists_symlinks=no], [gl_cv_glob_lists_symlinks=no])
fi])
if test $gl_cv_glob_lists_symlinks = no; then
GLOB_H=glob.h
fi
fi
rm -f conf$$-globtest
if test -n "$GLOB_H"; then
gl_GLOB_SUBSTITUTE
fi
])
# Prerequisites of lib/glob.*.
AC_DEFUN([gl_PREREQ_GLOB],
[ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl
AC_REQUIRE([AC_GNU_SOURCE])dnl
AC_REQUIRE([AC_HEADER_DIRENT])dnl
AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl
AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r])dnl
:])
# mbiter.m4 serial 2
dnl Copyright (C) 2005 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl autoconf tests required for use of mbiter.h
dnl From Bruno Haible.
AC_DEFUN([gl_MBITER],
[
AC_REQUIRE([AC_TYPE_MBSTATE_T])
dnl The following line is that so the user can test HAVE_MBRTOWC before
dnl #include "mbiter.h" or "mbuiter.h".
AC_REQUIRE([gl_FUNC_MBRTOWC])
:
])
#serial 2
# Copyright (C) 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_STAT_MACROS],
[
MU_LIBSOURCES([stat-macros.h])
AC_REQUIRE([AC_HEADER_STAT])
])
# stdint.m4 serial 4
dnl Copyright (C) 2001-2002, 2004-2005 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
dnl Test whether <stdint.h> is supported or must be substituted.
AC_DEFUN([gl_STDINT_H],
[dnl Check for <inttypes.h>.
AC_REQUIRE([gt_HEADER_INTTYPES_H])
dnl Check for <sys/inttypes.h>.
AC_CHECK_HEADERS([sys/inttypes.h])
AC_MSG_CHECKING([for stdint.h])
AC_CACHE_VAL(gl_cv_header_stdint_h, [
AC_TRY_COMPILE([#include <stdint.h>], [],
gl_cv_header_stdint_h=yes, gl_cv_header_stdint_h=no)])
AC_MSG_RESULT([$gl_cv_header_stdint_h])
if test $gl_cv_header_stdint_h = yes; then
AC_DEFINE(HAVE_STDINT_H, 1,
[Define if you have a working <stdint.h> header file.])
STDINT_H=''
else
STDINT_H='stdint.h'
dnl Is long == int64_t ?
AC_CACHE_CHECK([whether 'long' is 64 bit wide], gl_cv_long_bitsize_64, [
AC_TRY_COMPILE([
#define POW63 ((((((long) 1 << 15) << 15) << 15) << 15) << 3)
#define POW64 ((((((long) 1 << 15) << 15) << 15) << 15) << 4)
typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
], , gl_cv_long_bitsize_64=yes, gl_cv_long_bitsize_64=no)])
if test $gl_cv_long_bitsize_64 = yes; then
HAVE_LONG_64BIT=1
else
HAVE_LONG_64BIT=0
fi
AC_SUBST(HAVE_LONG_64BIT)
dnl Is long long == int64_t ?
AC_CACHE_CHECK([whether 'long long' is 64 bit wide], gl_cv_longlong_bitsize_64, [
AC_TRY_COMPILE([
#define POW63 ((((((long long) 1 << 15) << 15) << 15) << 15) << 3)
#define POW64 ((((((long long) 1 << 15) << 15) << 15) << 15) << 4)
typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
], , gl_cv_longlong_bitsize_64=yes, gl_cv_longlong_bitsize_64=no)])
if test $gl_cv_longlong_bitsize_64 = yes; then
HAVE_LONG_LONG_64BIT=1
else
HAVE_LONG_LONG_64BIT=0
fi
AC_SUBST(HAVE_LONG_LONG_64BIT)
fi
AC_SUBST(STDINT_H)
])
# strdup.m4 serial 6
dnl Copyright (C) 2002, 2003, 2004, 2005 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.
AC_DEFUN([gl_FUNC_STRDUP],
[
MU_LIBSOURCES([strdup.c, strdup.h])
MU_REPLACE_FUNCS(strdup)
AC_CHECK_DECLS_ONCE(strdup)
gl_PREREQ_STRDUP
])
# Prerequisites of lib/strdup.c.
AC_DEFUN([gl_PREREQ_STRDUP], [:])
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 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
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _FNMATCH_H
# define _FNMATCH_H 1
# ifdef __cplusplus
extern "C" {
# endif
/* We #undef these before defining them because some losing systems
(HP-UX A.08.07 for example) define these in <unistd.h>. */
# undef FNM_PATHNAME
# undef FNM_NOESCAPE
# undef FNM_PERIOD
/* Bits set in the FLAGS argument to `fnmatch'. */
# define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
# define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
# define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
# if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */
# endif
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
# define FNM_NOMATCH 1
/* This value is returned if the implementation does not support
`fnmatch'. Since this is not the case here it will never be
returned but the conformance test suites still require the symbol
to be defined. */
# ifdef _XOPEN_SOURCE
# define FNM_NOSYS (-1)
# endif
/* Match NAME against the file name pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */
extern int fnmatch (const char *__pattern, const char *__name,
int __flags);
# ifdef __cplusplus
}
# endif
#endif /* fnmatch.h */
/* Provide a working getlogin_r for systems which lack it.
Copyright (C) 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
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* written by Paul Eggert and Derek Price */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "getlogin_r.h"
#include <errno.h>
#include <string.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#if !HAVE_DECL_GETLOGIN
char *getlogin (void);
#endif
/* See getlogin_r.h for documentation. */
int
getlogin_r (char *name, size_t size)
{
char *n;
size_t nlen;
errno = 0;
n = getlogin ();
/* A system function like getlogin_r is never supposed to set errno
to zero, so make sure errno is nonzero here. ENOENT is a
reasonable errno value if getlogin returns NULL. */
if (!errno)
errno = ENOENT;
if (!n)
return errno;
nlen = strlen (n);
if (size <= nlen)
return ERANGE;
memcpy (name, n, nlen + 1);
return 0;
}
/* getlogin_r declaration
Copyright (C) 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
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Written by Paul Eggert and Derek Price. */
#include <stddef.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
/* Copies the user's login name to NAME.
The array pointed to by NAME has room for SIZE bytes.
Returns 0 if successful. Upon error, an error number is returned, or -1 in
the case that the login name cannot be found but no specific error is
provided (this case is hopefully rare but is left open by the POSIX spec).
See <http://www.opengroup.org/susv3xsh/getlogin.html>.
*/
#if !HAVE_DECL_GETLOGIN_R
int getlogin_r (char *name, size_t size);
#endif
/* Copyright (C) 1991,92,95-98,2000,2001,2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _GLOB_H
#define _GLOB_H 1
#ifndef __GLOB_GNULIB
# include <sys/cdefs.h>
#endif
__BEGIN_DECLS
/* We need `size_t' for the following definitions. */
#ifndef __size_t
# if defined __GNUC__ && __GNUC__ >= 2
typedef __SIZE_TYPE__ __size_t;
# ifdef __USE_XOPEN
typedef __SIZE_TYPE__ size_t;
# endif
# else
# include <stddef.h>
# ifndef __size_t
# define __size_t size_t
# endif
# endif
#else
/* The GNU CC stddef.h version defines __size_t as empty. We need a real
definition. */
# undef __size_t
# define __size_t size_t
#endif
/* Bits set in the FLAGS argument to `glob'. */
#define GLOB_ERR (1 << 0)/* Return on read errors. */
#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
#if !defined __USE_POSIX2 || defined __USE_BSD || defined __USE_GNU
# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
# define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */
# define GLOB_ONLYDIR (1 << 13)/* Match only directories. */
# define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
if the user name is not available. */
# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
#else
# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
GLOB_PERIOD)
#endif
/* Error returns from `glob'. */
#define GLOB_NOSPACE 1 /* Ran out of memory. */
#define GLOB_ABORTED 2 /* Read error. */
#define GLOB_NOMATCH 3 /* No matches found. */
#define GLOB_NOSYS 4 /* Not implemented. */
#ifdef __USE_GNU
/* Previous versions of this file defined GLOB_ABEND instead of
GLOB_ABORTED. Provide a compatibility definition here. */
# define GLOB_ABEND GLOB_ABORTED
#endif
/* Structure describing a globbing run. */
#ifdef __USE_GNU
struct stat;
#endif
typedef struct
{
__size_t gl_pathc; /* Count of paths matched by the pattern. */
char **gl_pathv; /* List of matched pathnames. */
__size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
/* If the GLOB_ALTDIRFUNC flag is set, the following functions
are used instead of the normal file access functions. */
void (*gl_closedir) (void *);
#ifdef __USE_GNU
struct dirent *(*gl_readdir) (void *);
#else
void *(*gl_readdir) (void *);
#endif
void *(*gl_opendir) (__const char *);
#ifdef __USE_GNU
int (*gl_lstat) (__const char *__restrict, struct stat *__restrict);
int (*gl_stat) (__const char *__restrict, struct stat *__restrict);
#else
int (*gl_lstat) (__const char *__restrict, void *__restrict);
int (*gl_stat) (__const char *__restrict, void *__restrict);
#endif
} glob_t;
#if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB
# ifdef __USE_GNU
struct stat64;
# endif
typedef struct
{
__size_t gl_pathc;
char **gl_pathv;
__size_t gl_offs;
int gl_flags;
/* If the GLOB_ALTDIRFUNC flag is set, the following functions
are used instead of the normal file access functions. */
void (*gl_closedir) (void *);
# ifdef __USE_GNU
struct dirent64 *(*gl_readdir) (void *);
# else
void *(*gl_readdir) (void *);
# endif
void *(*gl_opendir) (__const char *);
# ifdef __USE_GNU
int (*gl_lstat) (__const char *__restrict, struct stat64 *__restrict);
int (*gl_stat) (__const char *__restrict, struct stat64 *__restrict);
# else
int (*gl_lstat) (__const char *__restrict, void *__restrict);
int (*gl_stat) (__const char *__restrict, void *__restrict);
# endif
} glob64_t;
#endif
#if __USE_FILE_OFFSET64 && __GNUC__ < 2 && !defined __GLOB_GNULIB
# define glob glob64
# define globfree globfree64
#endif
/* Do glob searching for PATTERN, placing results in PGLOB.
The bits defined above may be set in FLAGS.
If a directory cannot be opened or read and ERRFUNC is not nil,
it is called with the pathname that caused the error, and the
`errno' value from the failing call; if it returns non-zero
`glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
Otherwise, `glob' returns zero. */
#if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2 || defined __GLOB_GNULIB
extern int glob (__const char *__restrict __pattern, int __flags,
int (*__errfunc) (__const char *, int),
glob_t *__restrict __pglob) __THROW;
/* Free storage allocated in PGLOB by a previous `glob' call. */
extern void globfree (glob_t *__pglob) __THROW;
#else
extern int __REDIRECT_NTH (glob, (__const char *__restrict __pattern,
int __flags,
int (*__errfunc) (__const char *, int),
glob_t *__restrict __pglob), glob64);
extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
#endif
#if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB
extern int glob64 (__const char *__restrict __pattern, int __flags,
int (*__errfunc) (__const char *, int),
glob64_t *__restrict __pglob) __THROW;
extern void globfree64 (glob64_t *__pglob) __THROW;
#endif
#ifdef __USE_GNU
/* Return nonzero if PATTERN contains any metacharacters.
Metacharacters can be quoted with backslashes if QUOTE is nonzero.
This function is not part of the interface specified by POSIX.2
but several programs want to use it. */
extern int glob_pattern_p (__const char *__pattern, int __quote) __THROW;
#endif
__END_DECLS
#endif /* glob.h */
/* glob_.h -- Find a path matching a pattern.
Copyright (C) 2005 Free Software Foundation, Inc.
Written by Derek Price <derek@ximbiot.com> & Paul Eggert <eggert@CS.UCLA.EDU>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef GLOB_H
#define GLOB_H 1
#ifdef HAVE_SYS_CDEFS_H
# include <sys/cdefs.h>
#endif
#include <stddef.h>
#ifndef __BEGIN_DECLS
# define __BEGIN_DECLS
# define __END_DECLS
#endif
#ifndef __THROW
# define __THROW
#endif
#ifndef __size_t
# define __size_t size_t
#endif
#ifndef __const
# define __const const
#endif
#ifndef __restrict
# define __restrict restrict
#endif
#ifndef __USE_GNU
# define __USE_GNU 1
#endif
#ifndef HAVE_DIRENT_H
# define dirent direct
#endif
#define glob rpl_glob
#define globfree rpl_globfree
#define glob_pattern_p rpl_glob_pattern_p
#define __GLOB_GNULIB 1
/* Now the standard GNU C Library header should work. */
#include "glob-libc.h"
#endif /* GLOB_H */
/* malloc() function that is glibc compatible.
Copyright (C) 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* written by Jim Meyering */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#undef malloc
#include <stdlib.h>
/* Allocate an N-byte block of memory from the heap.
If N is zero, allocate a 1-byte block. */
void *
rpl_malloc (size_t n)
{
if (n == 0)
n = 1;
return malloc (n);
}
/* Iterating through multibyte strings: macros for multi-byte encodings.
Copyright (C) 2001, 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
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Bruno Haible <bruno@clisp.org>. */
/* The macros in this file implement forward iteration through a
multi-byte string, without knowing its length a-priori.
With these macros, an iteration loop that looks like
char *iter;
for (iter = buf; *iter != '\0'; iter++)
{
do_something (*iter);
}
becomes
mbui_iterator_t iter;
for (mbui_init (iter, buf); mbui_avail (iter); mbui_advance (iter))
{
do_something (mbui_cur_ptr (iter), mb_len (mbui_cur (iter)));
}
The benefit of these macros over plain use of mbrtowc is:
- Handling of invalid multibyte sequences is possible without
making the code more complicated, while still preserving the
invalid multibyte sequences.
Compared to mbiter.h, the macros here don't need to know the string's
length a-priori. The downside is that at each step, the look-ahead
that guards against overrunning the terminating '\0' is more expensive.
The mbui_* macros are therefore suitable when there is a high probability
that only the first few multibyte characters need to be inspected.
Whereas the mbi_* macros are better if usually the iteration runs
through the entire string.
mbui_iterator_t
is a type usable for variable declarations.
mbui_init (iter, startptr)
initializes the iterator, starting at startptr.
mbui_avail (iter)
returns true if there are more multibyte chracters available before
the end of string is reached. In this case, mbui_cur (iter) is
initialized to the next multibyte chracter.
mbui_advance (iter)
advances the iterator by one multibyte character.
mbui_cur (iter)
returns the current multibyte character, of type mbchar_t. All the
macros defined in mbchar.h can be used on it.
mbui_cur_ptr (iter)
return a pointer to the beginning of the current multibyte character.
mbui_reloc (iter, ptrdiff)
relocates iterator when the string is moved by ptrdiff bytes.
Here are the function prototypes of the macros.
extern void mbui_init (mbui_iterator_t iter, const char *startptr);
extern bool mbui_avail (mbui_iterator_t iter);
extern void mbui_advance (mbui_iterator_t iter);
extern mbchar_t mbui_cur (mbui_iterator_t iter);
extern const char * mbui_cur_ptr (mbui_iterator_t iter);
extern void mbui_reloc (mbui_iterator_t iter, ptrdiff_t ptrdiff);
*/
#ifndef _MBUITER_H
#define _MBUITER_H 1
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
<wchar.h>.
BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
<wchar.h>. */
#include <stdio.h>
#include <time.h>
#include <wchar.h>
#include "mbchar.h"
#include "strnlen1.h"
struct mbuiter_multi
{
bool in_shift; /* true if next byte may not be interpreted as ASCII */
mbstate_t state; /* if in_shift: current shift state */
bool next_done; /* true if mbui_avail has already filled the following */
struct mbchar cur; /* the current character:
const char *cur.ptr pointer to current character
The following are only valid after mbui_avail.
size_t cur.bytes number of bytes of current character
bool cur.wc_valid true if wc is a valid wide character
wchar_t cur.wc if wc_valid: the current character
*/
};
static inline void
mbuiter_multi_next (struct mbuiter_multi *iter)
{
if (iter->next_done)
return;
if (iter->in_shift)
goto with_shift;
/* Handle most ASCII characters quickly, without calling mbrtowc(). */
if (is_basic (*iter->cur.ptr))
{
/* These characters are part of the basic character set. ISO C 99
guarantees that their wide character code is identical to their
char code. */
iter->cur.bytes = 1;
iter->cur.wc = *iter->cur.ptr;
iter->cur.wc_valid = true;
}
else
{
assert (mbsinit (&iter->state));
iter->in_shift = true;
with_shift:
iter->cur.bytes = mbrtowc (&iter->cur.wc, iter->cur.ptr,
strnlen1 (iter->cur.ptr, MB_CUR_MAX),
&iter->state);
if (iter->cur.bytes == (size_t) -1)
{
/* An invalid multibyte sequence was encountered. */
iter->cur.bytes = 1;
iter->cur.wc_valid = false;
/* Whether to set iter->in_shift = false and reset iter->state
or not is not very important; the string is bogus anyway. */
}
else if (iter->cur.bytes == (size_t) -2)
{
/* An incomplete multibyte character at the end. */
iter->cur.bytes = strlen (iter->cur.ptr);
iter->cur.wc_valid = false;
/* Whether to set iter->in_shift = false and reset iter->state
or not is not important; the string end is reached anyway. */
}
else
{
if (iter->cur.bytes == 0)
{
/* A null wide character was encountered. */
iter->cur.bytes = 1;
assert (*iter->cur.ptr == '\0');
assert (iter->cur.wc == 0);
}
iter->cur.wc_valid = true;
/* When in the initial state, we can go back treating ASCII
characters more quickly. */
if (mbsinit (&iter->state))
iter->in_shift = false;
}
}
iter->next_done = true;
}
static inline void
mbuiter_multi_reloc (struct mbuiter_multi *iter, ptrdiff_t ptrdiff)
{
iter->cur.ptr += ptrdiff;
}
/* Iteration macros. */
typedef struct mbuiter_multi mbui_iterator_t;
#define mbui_init(iter, startptr) \
((iter).cur.ptr = (startptr), \
(iter).in_shift = false, memset (&(iter).state, '\0', sizeof (mbstate_t)), \
(iter).next_done = false)
#define mbui_avail(iter) \
(mbuiter_multi_next (&(iter)), !mb_isnul ((iter).cur))
#define mbui_advance(iter) \
((iter).cur.ptr += (iter).cur.bytes, (iter).next_done = false)
/* Access to the current character. */
#define mbui_cur(iter) (iter).cur
#define mbui_cur_ptr(iter) (iter).cur.ptr
/* Relocation. */
#define mbui_reloc(iter, ptrdiff) mbuiter_multi_reloc (&iter, ptrdiff)
#endif /* _MBUITER_H */
/* stat-related macros
Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Written by Paul Eggert and Jim Meyering. */
#ifndef STAT_MACROS_H
# define STAT_MACROS_H 1
# if ! defined S_ISREG && ! defined S_IFREG
# error "you must include <sys/stat.h> before including this file"
# endif
# ifndef S_IFMT
# define S_IFMT 0170000
# endif
# if STAT_MACROS_BROKEN
# undef S_ISBLK
# undef S_ISCHR
# undef S_ISDIR
# undef S_ISDOOR
# undef S_ISFIFO
# undef S_ISLNK
# undef S_ISNAM
# undef S_ISMPB
# undef S_ISMPC
# undef S_ISNWK
# undef S_ISREG
# undef S_ISSOCK
# endif
# ifndef S_ISBLK
# ifdef S_IFBLK
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
# else
# define S_ISBLK(m) 0
# endif
# endif
# ifndef S_ISCHR
# ifdef S_IFCHR
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
# else
# define S_ISCHR(m) 0
# endif
# endif
# ifndef S_ISDIR
# ifdef S_IFDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
# else
# define S_ISDIR(m) 0
# endif
# endif
# ifndef S_ISDOOR /* Solaris 2.5 and up */
# ifdef S_IFDOOR
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
# else
# define S_ISDOOR(m) 0
# endif
# endif
# ifndef S_ISFIFO
# ifdef S_IFIFO
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
# else
# define S_ISFIFO(m) 0
# endif
# endif
# ifndef S_ISLNK
# ifdef S_IFLNK
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
# else
# define S_ISLNK(m) 0
# endif
# endif
# ifndef S_ISMPB /* V7 */
# ifdef S_IFMPB
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
# else
# define S_ISMPB(m) 0
# define S_ISMPC(m) 0
# endif
# endif
# ifndef S_ISNAM /* Xenix */
# ifdef S_IFNAM
# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
# else
# define S_ISNAM(m) 0
# endif
# endif
# ifndef S_ISNWK /* HP/UX */
# ifdef S_IFNWK
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
# else
# define S_ISNWK(m) 0
# endif
# endif
# ifndef S_ISREG
# ifdef S_IFREG
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
# else
# define S_ISREG(m) 0
# endif
# endif
# ifndef S_ISSOCK
# ifdef S_IFSOCK
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
# else
# define S_ISSOCK(m) 0
# endif
# endif
# ifndef S_TYPEISMQ
# define S_TYPEISMQ(p) 0
# endif
# ifndef S_TYPEISTMO
# define S_TYPEISTMO(p) 0
# endif
# ifndef S_TYPEISSEM
# ifdef S_INSEM
# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
# else
# define S_TYPEISSEM(p) 0
# endif
# endif
# ifndef S_TYPEISSHM
# ifdef S_INSHD
# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
# else
# define S_TYPEISSHM(p) 0
# endif
# endif
/* contiguous */
# ifndef S_ISCTG
# define S_ISCTG(p) 0
# endif
/* Cray DMF (data migration facility): off line, with data */
# ifndef S_ISOFD
# define S_ISOFD(p) 0
# endif
/* Cray DMF (data migration facility): off line, with no data */
# ifndef S_ISOFL
# define S_ISOFL(p) 0
# endif
/* If any of the following are undefined,
define them to their de facto standard values. */
# if !S_ISUID
# define S_ISUID 04000
# endif
# if !S_ISGID
# define S_ISGID 02000
# endif
/* S_ISVTX is a common extension to POSIX. */
# ifndef S_ISVTX
# define S_ISVTX 01000
# endif
# if !S_IRUSR && S_IREAD
# define S_IRUSR S_IREAD
# endif
# if !S_IRUSR
# define S_IRUSR 00400
# endif
# if !S_IRGRP
# define S_IRGRP (S_IRUSR >> 3)
# endif
# if !S_IROTH
# define S_IROTH (S_IRUSR >> 6)
# endif
# if !S_IWUSR && S_IWRITE
# define S_IWUSR S_IWRITE
# endif
# if !S_IWUSR
# define S_IWUSR 00200
# endif
# if !S_IWGRP
# define S_IWGRP (S_IWUSR >> 3)
# endif
# if !S_IWOTH
# define S_IWOTH (S_IWUSR >> 6)
# endif
# if !S_IXUSR && S_IEXEC
# define S_IXUSR S_IEXEC
# endif
# if !S_IXUSR
# define S_IXUSR 00100
# endif
# if !S_IXGRP
# define S_IXGRP (S_IXUSR >> 3)
# endif
# if !S_IXOTH
# define S_IXOTH (S_IXUSR >> 6)
# endif
# if !S_IRWXU
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
# endif
# if !S_IRWXG
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
# endif
# if !S_IRWXO
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
# endif
/* S_IXUGO is a common extension to POSIX. */
# if !S_IXUGO
# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
# endif
# ifndef S_IRWXUGO
# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
# endif
/* All the mode bits that can be affected by chmod. */
# define CHMOD_MODE_BITS \
(S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
#endif /* STAT_MACROS_H */
/* Copyright (C) 2001-2002, 2004-2005 Free Software Foundation, Inc.
Written by Bruno Haible, Sam Steingold, Peter Burwood.
This file is part of gnulib.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _STDINT_H
#define _STDINT_H
/*
* ISO C 99 <stdint.h> for platforms that lack it.
* <http://www.opengroup.org/onlinepubs/007904975/basedefs/stdint.h.html>
*/
/* Get wchar_t, WCHAR_MIN, WCHAR_MAX. */
#include <stddef.h>
/* Get CHAR_BIT, LONG_MIN, LONG_MAX, ULONG_MAX. */
#include <limits.h>
/* Get those types that are already defined in other system include files. */
#if defined(__FreeBSD__)
# include <sys/inttypes.h>
#endif
#if defined(__sun) && HAVE_SYS_INTTYPES_H
# include <sys/inttypes.h>
/* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.
But note that <sys/int_types.h> contains only the type definitions! */
# define _STDINT_H_HAVE_SYSTEM_INTTYPES
#endif
#if (defined(__hpux) || defined(_AIX)) && HAVE_INTTYPES_H
# include <inttypes.h>
/* HP-UX 10 <inttypes.h> has nearly everything, except UINT_LEAST8_MAX,
UINT_FAST8_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */
/* AIX 4 <inttypes.h> has nearly everything, except INTPTR_MIN, INTPTR_MAX,
UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */
# define _STDINT_H_HAVE_SYSTEM_INTTYPES
#endif
#if !(defined(UNIX_CYGWIN32) && defined(__BIT_TYPES_DEFINED__))
# define _STDINT_H_NEED_SIGNED_INT_TYPES
#endif
#if !defined(_STDINT_H_HAVE_SYSTEM_INTTYPES)
/* 7.18.1.1. Exact-width integer types */
#if !defined(__FreeBSD__)
#ifdef _STDINT_H_NEED_SIGNED_INT_TYPES
typedef signed char int8_t;
#endif
typedef unsigned char uint8_t;
#ifdef _STDINT_H_NEED_SIGNED_INT_TYPES
typedef short int16_t;
#endif
typedef unsigned short uint16_t;
#ifdef _STDINT_H_NEED_SIGNED_INT_TYPES
typedef int int32_t;
#endif
typedef unsigned int uint32_t;
#if @HAVE_LONG_64BIT@
#ifdef _STDINT_H_NEED_SIGNED_INT_TYPES
typedef long int64_t;
#endif
typedef unsigned long uint64_t;
#define _STDINT_H_HAVE_INT64
#elif @HAVE_LONG_LONG_64BIT@
#ifdef _STDINT_H_NEED_SIGNED_INT_TYPES
typedef long long int64_t;
#endif
typedef unsigned long long uint64_t;
#define _STDINT_H_HAVE_INT64
#elif defined(_MSC_VER)
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#define _STDINT_H_HAVE_INT64
#endif
#endif /* !FreeBSD */
/* 7.18.1.2. Minimum-width integer types */
typedef int8_t int_least8_t;
typedef uint8_t uint_least8_t;
typedef int16_t int_least16_t;
typedef uint16_t uint_least16_t;
typedef int32_t int_least32_t;
typedef uint32_t uint_least32_t;
#ifdef _STDINT_H_HAVE_INT64
typedef int64_t int_least64_t;
typedef uint64_t uint_least64_t;
#endif
/* 7.18.1.3. Fastest minimum-width integer types */
typedef int32_t int_fast8_t;
typedef uint32_t uint_fast8_t;
typedef int32_t int_fast16_t;
typedef uint32_t uint_fast16_t;
typedef int32_t int_fast32_t;
typedef uint32_t uint_fast32_t;
#ifdef _STDINT_H_HAVE_INT64
typedef int64_t int_fast64_t;
typedef uint64_t uint_fast64_t;
#endif
/* 7.18.1.4. Integer types capable of holding object pointers */
#if !defined(__FreeBSD__)
/* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long),
but this doesn't matter here. */
typedef long intptr_t;
typedef unsigned long uintptr_t;
#endif /* !FreeBSD */
/* 7.18.1.5. Greatest-width integer types */
#ifdef _STDINT_H_HAVE_INT64
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
#else
typedef int32_t intmax_t;
typedef uint32_t uintmax_t;
#endif
/* 7.18.2. Limits of specified-width integer types */
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
/* 7.18.2.1. Limits of exact-width integer types */
#define INT8_MIN -128
#define INT8_MAX 127
#define UINT8_MAX 255U
#define INT16_MIN -32768
#define INT16_MAX 32767
#define UINT16_MAX 65535U
#define INT32_MIN (~INT32_MAX)
#define INT32_MAX 2147483647
#define UINT32_MAX 4294967295U
#ifdef _STDINT_H_HAVE_INT64
#define INT64_MIN (~INT64_MAX)
#if @HAVE_LONG_64BIT@
#define INT64_MAX 9223372036854775807L
#define UINT64_MAX 18446744073709551615UL
#elif @HAVE_LONG_LONG_64BIT@
#define INT64_MAX 9223372036854775807LL
#define UINT64_MAX 18446744073709551615ULL
#elif defined(_MSC_VER)
#define INT64_MAX 9223372036854775807i64
#define UINT64_MAX 18446744073709551615ui64
#endif
#endif
/* 7.18.2.2. Limits of minimum-width integer types */
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#ifdef _STDINT_H_HAVE_INT64
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST64_MAX UINT64_MAX
#endif
/* 7.18.2.3. Limits of fastest minimum-width integer types */
#define INT_FAST8_MIN INT32_MIN
#define INT_FAST8_MAX INT32_MAX
#define UINT_FAST8_MAX UINT32_MAX
#define INT_FAST16_MIN INT32_MIN
#define INT_FAST16_MAX INT32_MAX
#define UINT_FAST16_MAX UINT32_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define UINT_FAST32_MAX UINT32_MAX
#ifdef _STDINT_H_HAVE_INT64
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST64_MAX UINT64_MAX
#endif
/* 7.18.2.4. Limits of integer types capable of holding object pointers */
#define INTPTR_MIN LONG_MIN
#define INTPTR_MAX LONG_MAX
#define UINTPTR_MAX ULONG_MAX
/* 7.18.2.5. Limits of greatest-width integer types */
#ifdef _STDINT_H_HAVE_INT64
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
#else
#define INTMAX_MIN INT32_MIN
#define INTMAX_MAX INT32_MAX
#define UINTMAX_MAX UINT32_MAX
#endif
/* 7.18.3. Limits of other integer types */
#define PTRDIFF_MIN (~(ptrdiff_t)0 << (sizeof(ptrdiff_t)*CHAR_BIT-1))
#define PTRDIFF_MAX (~PTRDIFF_MIN)
/* This may be wrong... */
#define SIG_ATOMIC_MIN 0
#define SIG_ATOMIC_MAX 127
#define SIZE_MAX (~(size_t)0)
/* wchar_t limits already defined in <stddef.h>. */
/* wint_t limits already defined in <wchar.h>. */
#endif
/* 7.18.4. Macros for integer constants */
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
/* 7.18.4.1. Macros for minimum-width integer constants */
#define INT8_C(x) x
#define UINT8_C(x) x##U
#define INT16_C(x) x
#define UINT16_C(x) x##U
#define INT32_C(x) x
#define UINT32_C(x) x##U
#if @HAVE_LONG_64BIT@
#define INT64_C(x) x##L
#define UINT64_C(x) x##UL
#elif @HAVE_LONG_LONG_64BIT@
#define INT64_C(x) x##LL
#define UINT64_C(x) x##ULL
#elif defined(_MSC_VER)
#define INT64_C(x) x##i64
#define UINT64_C(x) x##ui64
#endif
/* 7.18.4.2. Macros for greatest-width integer constants */
#if @HAVE_LONG_64BIT@
#define INTMAX_C(x) x##L
#define UINTMAX_C(x) x##UL
#elif @HAVE_LONG_LONG_64BIT@
#define INTMAX_C(x) x##LL
#define UINTMAX_C(x) x##ULL
#elif defined(_MSC_VER)
#define INTMAX_C(x) x##i64
#define UINTMAX_C(x) x##ui64
#else
#define INTMAX_C(x) x
#define UINTMAX_C(x) x##U
#endif
#endif
#endif /* !_STDINT_H_HAVE_SYSTEM_INTTYPES */
#endif /* _STDINT_H */
/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004 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
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifndef _LIBC
/* Get specification. */
# include "strdup.h"
#endif
#include <stdlib.h>
#include <string.h>
#undef __strdup
#undef strdup
#ifndef weak_alias
# define __strdup strdup
#endif
/* Duplicate S, returning an identical malloc'd string. */
char *
__strdup (const char *s)
{
size_t len = strlen (s) + 1;
void *new = malloc (len);
if (new == NULL)
return NULL;
return (char *) memcpy (new, s, len);
}
#ifdef libc_hidden_def
libc_hidden_def (__strdup)
#endif
#ifdef weak_alias
weak_alias (__strdup, strdup)
#endif
/* strdup.h -- duplicate a string
Copyright (C) 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef STRDUP_H_
#define STRDUP_H_
/* Get strdup declaration, if available. */
#include <string.h>
#if defined HAVE_DECL_STRDUP && !HAVE_DECL_STRDUP && !defined strdup
/* Duplicate S, returning an identical malloc'd string. */
extern char *strdup (const char *s);
#endif
#endif /* STRDUP_H_ */