code:
/* C++ compatible function declaration macros.
   Copyright (C) 2010-2017 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */

#ifndef _GL_CXXDEFS_H
#define _GL_CXXDEFS_H

/* Begin/end the GNULIB_NAMESPACE namespace.  */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
# define _GL_END_NAMESPACE }
#else
# define _GL_BEGIN_NAMESPACE
# define _GL_END_NAMESPACE
#endif

/* The three most frequent use cases of these macros are:

   * For providing a substitute for a function that is missing on some
     platforms, but is declared and works fine on the platforms on which
     it exists:

       #if @GNULIB_FOO@
       # if !@HAVE_FOO@
       _GL_FUNCDECL_SYS (foo, ...);
       # endif
       _GL_CXXALIAS_SYS (foo, ...);
       _GL_CXXALIASWARN (foo);
       #elif defined GNULIB_POSIXCHECK
       ...
       #endif

   * For providing a replacement for a function that exists on all platforms,
     but is broken/insufficient and needs to be replaced on some platforms:

       #if @GNULIB_FOO@
       # if @REPLACE_FOO@
       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
       #   undef foo
       #   define foo rpl_foo
       #  endif
       _GL_FUNCDECL_RPL (foo, ...);
       _GL_CXXALIAS_RPL (foo, ...);
       # else
       _GL_CXXALIAS_SYS (foo, ...);
       # endif
       _GL_CXXALIASWARN (foo);
       #elif defined GNULIB_POSIXCHECK
       ...
       #endif

   * For providing a replacement for a function that exists on some platforms
     but is broken/insufficient and needs to be replaced on some of them and
     is additionally either missing or undeclared on some other platforms:

       #if @GNULIB_FOO@
       # if @REPLACE_FOO@
       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
       #   undef foo
       #   define foo rpl_foo
       #  endif
       _GL_FUNCDECL_RPL (foo, ...);
       _GL_CXXALIAS_RPL (foo, ...);
       # else
       #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
       _GL_FUNCDECL_SYS (foo, ...);
       #  endif
       _GL_CXXALIAS_SYS (foo, ...);
       # endif
       _GL_CXXALIASWARN (foo);
       #elif defined GNULIB_POSIXCHECK
       ...
       #endif
*/

/* _GL_EXTERN_C declaration;
   performs the declaration with C linkage.  */
#if defined __cplusplus
# define _GL_EXTERN_C extern "C"
#else
# define _GL_EXTERN_C extern
#endif

/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
   declares a replacement function, named rpl_func, with the given prototype,
   consisting of return type, parameters, and attributes.
   Example:
     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
                                  _GL_ARG_NONNULL ((1)));
 */
#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
  _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
  _GL_EXTERN_C rettype rpl_func parameters_and_attributes

/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
   declares the system function, named func, with the given prototype,
   consisting of return type, parameters, and attributes.
   Example:
     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
                                  _GL_ARG_NONNULL ((1)));
 */
#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
  _GL_EXTERN_C rettype func parameters_and_attributes

/* _GL_CXXALIAS_RPL (func, rettype, parameters);
   declares a C++ alias called GNULIB_NAMESPACE::func
   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
   Example:
     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));

   Wrapping rpl_func in an object with an inline conversion operator
   avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
   actually used in the program.  */
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
    namespace GNULIB_NAMESPACE                                \
    {                                                         \
      static const struct _gl_ ## func ## _wrapper            \
      {                                                       \
        typedef rettype (*type) parameters;                   \
                                                              \
        inline operator type () const                         \
        {                                                     \
          return ::rpl_func;                                  \
        }                                                     \
      } func = {};                                            \
    }                                                         \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#endif

/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
   except that the C function rpl_func may have a slightly different
   declaration.  A cast is used to silence the "invalid conversion" error
   that would otherwise occur.  */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
    namespace GNULIB_NAMESPACE                                     \
    {                                                              \
      static const struct _gl_ ## func ## _wrapper                 \
      {                                                            \
        typedef rettype (*type) parameters;                        \
                                                                   \
        inline operator type () const                              \
        {                                                          \
          return reinterpret_cast<type>(::rpl_func);               \
        }                                                          \
      } func = {};                                                 \
    }                                                              \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#endif

/* _GL_CXXALIAS_SYS (func, rettype, parameters);
   declares a C++ alias called GNULIB_NAMESPACE::func
   that redirects to the system provided function func, if GNULIB_NAMESPACE
   is defined.
   Example:
     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));

   Wrapping func in an object with an inline conversion operator
   avoids a reference to func unless GNULIB_NAMESPACE::func is
   actually used in the program.  */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
    namespace GNULIB_NAMESPACE                                \
    {                                                         \
      static const struct _gl_ ## func ## _wrapper            \
      {                                                       \
        typedef rettype (*type) parameters;                   \
                                                              \
        inline operator type () const                         \
        {                                                     \
          return ::func;                                      \
        }                                                     \
      } func = {};                                            \
    }                                                         \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#endif

/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
   except that the C function func may have a slightly different declaration.
   A cast is used to silence the "invalid conversion" error that would
   otherwise occur.  */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
    namespace GNULIB_NAMESPACE                          \
    {                                                   \
      static const struct _gl_ ## func ## _wrapper      \
      {                                                 \
        typedef rettype (*type) parameters;             \
                                                        \
        inline operator type () const                   \
        {                                               \
          return reinterpret_cast<type>(::func);        \
        }                                               \
      } func = {};                                      \
    }                                                   \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#endif

/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
   except that the C function is picked among a set of overloaded functions,
   namely the one with rettype2 and parameters2.  Two consecutive casts
   are used to silence the "cannot find a match" and "invalid conversion"
   errors that would otherwise occur.  */
#if defined __cplusplus && defined GNULIB_NAMESPACE
  /* The outer cast must be a reinterpret_cast.
     The inner cast: When the function is defined as a set of overloaded
     functions, it works as a static_cast<>, choosing the designated variant.
     When the function is defined as a single variant, it works as a
     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
    namespace GNULIB_NAMESPACE                                                \
    {                                                                         \
      static const struct _gl_ ## func ## _wrapper                            \
      {                                                                       \
        typedef rettype (*type) parameters;                                   \
                                                                              \
        inline operator type () const                                         \
        {                                                                     \
          return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
        }                                                                     \
      } func = {};                                                            \
    }                                                                         \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#endif

/* _GL_CXXALIASWARN (func);
   causes a warning to be emitted when ::func is used but not when
   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
   variants.  */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN(func) \
   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN_1(func,namespace) \
   _GL_CXXALIASWARN_2 (func, namespace)
/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
   we enable the warning only when not optimizing.  */
# if !__OPTIMIZE__
#  define _GL_CXXALIASWARN_2(func,namespace) \
    _GL_WARN_ON_USE (func, \
                     "The symbol ::" #func " refers to the system function. " \
                     "Use " #namespace "::" #func " instead.")
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
#  define _GL_CXXALIASWARN_2(func,namespace) \
     extern __typeof__ (func) func
# else
#  define _GL_CXXALIASWARN_2(func,namespace) \
     _GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN(func) \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#endif

/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
   causes a warning to be emitted when the given overloaded variant of ::func
   is used but not when GNULIB_NAMESPACE::func is used.  */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
   _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
                        GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
   we enable the warning only when not optimizing.  */
# if !__OPTIMIZE__
#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
    _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
                         "The symbol ::" #func " refers to the system function. " \
                         "Use " #namespace "::" #func " instead.")
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
     extern __typeof__ (func) func
# else
#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
     _GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
    _GL_EXTERN_C int _gl_cxxalias_dummy
#endif

#endif /* _GL_CXXDEFS_H */


code:
#! /bin/sh
# Output a system dependent table of character encoding aliases.
#
#   Copyright (C) 2000-2004, 2006-2017 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 3, 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, see <http://www.gnu.org/licenses/>.
#
# The table consists of lines of the form
#    ALIAS  CANONICAL
#
# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)".
# ALIAS is compared in a case sensitive way.
#
# CANONICAL is the GNU canonical name for this character encoding.
# It must be an encoding supported by libiconv. Support by GNU libc is
# also desirable. CANONICAL is case insensitive. Usually an upper case
# MIME charset name is preferred.
# The current list of GNU canonical charset names is as follows.
#
#       name              MIME?             used by which systems
#                                    (darwin = Mac OS X, woe32 = native Windows)
#
#   ASCII, ANSI_X3.4-1968       glibc solaris freebsd netbsd darwin cygwin
#   ISO-8859-1              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
#   ISO-8859-2              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
#   ISO-8859-3              Y   glibc solaris cygwin
#   ISO-8859-4              Y   osf solaris freebsd netbsd openbsd darwin
#   ISO-8859-5              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
#   ISO-8859-6              Y   glibc aix hpux solaris cygwin
#   ISO-8859-7              Y   glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin
#   ISO-8859-8              Y   glibc aix hpux osf solaris cygwin
#   ISO-8859-9              Y   glibc aix hpux irix osf solaris darwin cygwin
#   ISO-8859-13                 glibc netbsd openbsd darwin cygwin
#   ISO-8859-14                 glibc cygwin
#   ISO-8859-15                 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin
#   KOI8-R                  Y   glibc solaris freebsd netbsd openbsd darwin
#   KOI8-U                  Y   glibc freebsd netbsd openbsd darwin cygwin
#   KOI8-T                      glibc
#   CP437                       dos
#   CP775                       dos
#   CP850                       aix osf dos
#   CP852                       dos
#   CP855                       dos
#   CP856                       aix
#   CP857                       dos
#   CP861                       dos
#   CP862                       dos
#   CP864                       dos
#   CP865                       dos
#   CP866                       freebsd netbsd openbsd darwin dos
#   CP869                       dos
#   CP874                       woe32 dos
#   CP922                       aix
#   CP932                       aix cygwin woe32 dos
#   CP943                       aix
#   CP949                       osf darwin woe32 dos
#   CP950                       woe32 dos
#   CP1046                      aix
#   CP1124                      aix
#   CP1125                      dos
#   CP1129                      aix
#   CP1131                      darwin
#   CP1250                      woe32
#   CP1251                      glibc solaris netbsd openbsd darwin cygwin woe32
#   CP1252                      aix woe32
#   CP1253                      woe32
#   CP1254                      woe32
#   CP1255                      glibc woe32
#   CP1256                      woe32
#   CP1257                      woe32
#   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 cygwin
#   EUC-TW                      glibc aix hpux irix osf solaris netbsd
#   BIG5                    Y   glibc aix hpux osf solaris freebsd netbsd darwin cygwin
#   BIG5-HKSCS                  glibc solaris darwin
#   GBK                         glibc aix osf solaris darwin cygwin woe32 dos
#   GB18030                     glibc solaris netbsd darwin
#   SHIFT_JIS               Y   hpux osf solaris freebsd netbsd darwin
#   JOHAB                       glibc solaris woe32
#   TIS-620                     glibc aix hpux osf solaris cygwin
#   VISCII                  Y   glibc
#   TCVN5712-1                  glibc
#   ARMSCII-8                   glibc darwin
#   GEORGIAN-PS                 glibc cygwin
#   PT154                       glibc
#   HP-ROMAN8                   hpux
#   HP-ARABIC8                  hpux
#   HP-GREEK8                   hpux
#   HP-HEBREW8                  hpux
#   HP-TURKISH8                 hpux
#   HP-KANA8                    hpux
#   DEC-KANJI                   osf
#   DEC-HANYU                   osf
#   UTF-8                   Y   glibc aix hpux osf solaris netbsd darwin cygwin
#
# Note: Names which are not marked as being a MIME name should not be used in
# Internet protocols for information interchange (mail, news, etc.).
#
# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
# must understand both names and treat them as equivalent.
#
# The first argument passed to this file is the canonical host specification,
#    CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
#    CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM

host="$1"
os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'`
echo "# This file contains a table of character encoding aliases,"
echo "# suitable for operating system '${os}'."
echo "# It was automatically generated from config.charset."
# List of references, updated during installation:
echo "# Packages using this file: "
case "$os" in
  linux-gnulibc1*)
    # Linux libc5 doesn't have nl_langinfo(CODESET); therefore
    # localcharset.c falls back to using the full locale name
    # from the environment variables.
    echo "C ASCII"
    echo "POSIX ASCII"
    for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
             en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
             en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
             es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
             et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
             fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
             it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
             sv_FI sv_SE; do
      echo "$l ISO-8859-1"
      echo "$l.iso-8859-1 ISO-8859-1"
      echo "$l.iso-8859-15 ISO-8859-15"
      echo "$l.iso-8859-15@euro ISO-8859-15"
      echo "$l@euro ISO-8859-15"
      echo "$l.cp-437 CP437"
      echo "$l.cp-850 CP850"
      echo "$l.cp-1252 CP1252"
      echo "$l.cp-1252@euro CP1252"
      #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
      echo "$l.utf-8 UTF-8"
      echo "$l.utf-8@euro UTF-8"
    done
    for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
             sl_SI sr sr_CS sr_YU; do
      echo "$l ISO-8859-2"
      echo "$l.iso-8859-2 ISO-8859-2"
      echo "$l.cp-852 CP852"
      echo "$l.cp-1250 CP1250"
      echo "$l.utf-8 UTF-8"
    done
    for l in mk mk_MK ru ru_RU; do
      echo "$l ISO-8859-5"
      echo "$l.iso-8859-5 ISO-8859-5"
      echo "$l.koi8-r KOI8-R"
      echo "$l.cp-866 CP866"
      echo "$l.cp-1251 CP1251"
      echo "$l.utf-8 UTF-8"
    done
    for l in ar ar_SA; do
      echo "$l ISO-8859-6"
      echo "$l.iso-8859-6 ISO-8859-6"
      echo "$l.cp-864 CP864"
      #echo "$l.cp-868 CP868" # not a commonly used encoding
      echo "$l.cp-1256 CP1256"
      echo "$l.utf-8 UTF-8"
    done
    for l in el el_GR gr gr_GR; do
      echo "$l ISO-8859-7"
      echo "$l.iso-8859-7 ISO-8859-7"
      echo "$l.cp-869 CP869"
      echo "$l.cp-1253 CP1253"
      echo "$l.cp-1253@euro CP1253"
      echo "$l.utf-8 UTF-8"
      echo "$l.utf-8@euro UTF-8"
    done
    for l in he he_IL iw iw_IL; do
      echo "$l ISO-8859-8"
      echo "$l.iso-8859-8 ISO-8859-8"
      echo "$l.cp-862 CP862"
      echo "$l.cp-1255 CP1255"
      echo "$l.utf-8 UTF-8"
    done
    for l in tr tr_TR; do
      echo "$l ISO-8859-9"
      echo "$l.iso-8859-9 ISO-8859-9"
      echo "$l.cp-857 CP857"
      echo "$l.cp-1254 CP1254"
      echo "$l.utf-8 UTF-8"
    done
    for l in lt lt_LT lv lv_LV; do
      #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
      echo "$l ISO-8859-13"
    done
    for l in ru_UA uk uk_UA; do
      echo "$l KOI8-U"
    done
    for l in zh zh_CN; do
      #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
      echo "$l GB2312"
    done
    for l in ja ja_JP ja_JP.EUC; do
      echo "$l EUC-JP"
    done
    for l in ko ko_KR; do
      echo "$l EUC-KR"
    done
    for l in th th_TH; do
      echo "$l TIS-620"
    done
    for l in fa fa_IR; do
      #echo "$l ISIRI-3342" # a broken encoding
      echo "$l.utf-8 UTF-8"
    done
    ;;
  linux* | *-gnu*)
    # With glibc-2.1 or newer, we don't need any canonicalization,
    # because glibc has iconv and both glibc and libiconv support all
    # GNU canonical names directly. Therefore, the Makefile does not
    # need to install the alias file at all.
    # The following applies only to glibc-2.0.x and older libcs.
    echo "ISO_646.IRV:1983 ASCII"
    ;;
  aix*)
    echo "ISO8859-1 ISO-8859-1"
    echo "ISO8859-2 ISO-8859-2"
    echo "ISO8859-5 ISO-8859-5"
    echo "ISO8859-6 ISO-8859-6"
    echo "ISO8859-7 ISO-8859-7"
    echo "ISO8859-8 ISO-8859-8"
    echo "ISO8859-9 ISO-8859-9"
    echo "ISO8859-15 ISO-8859-15"
    echo "IBM-850 CP850"
    echo "IBM-856 CP856"
    echo "IBM-921 ISO-8859-13"
    echo "IBM-922 CP922"
    echo "IBM-932 CP932"
    echo "IBM-943 CP943"
    echo "IBM-1046 CP1046"
    echo "IBM-1124 CP1124"
    echo "IBM-1129 CP1129"
    echo "IBM-1252 CP1252"
    echo "IBM-eucCN GB2312"
    echo "IBM-eucJP EUC-JP"
    echo "IBM-eucKR EUC-KR"
    echo "IBM-eucTW EUC-TW"
    echo "big5 BIG5"
    echo "GBK GBK"
    echo "TIS-620 TIS-620"
    echo "UTF-8 UTF-8"
    ;;
  hpux*)
    echo "iso88591 ISO-8859-1"
    echo "iso88592 ISO-8859-2"
    echo "iso88595 ISO-8859-5"
    echo "iso88596 ISO-8859-6"
    echo "iso88597 ISO-8859-7"
    echo "iso88598 ISO-8859-8"
    echo "iso88599 ISO-8859-9"
    echo "iso885915 ISO-8859-15"
    echo "roman8 HP-ROMAN8"
    echo "arabic8 HP-ARABIC8"
    echo "greek8 HP-GREEK8"
    echo "hebrew8 HP-HEBREW8"
    echo "turkish8 HP-TURKISH8"
    echo "kana8 HP-KANA8"
    echo "tis620 TIS-620"
    echo "big5 BIG5"
    echo "eucJP EUC-JP"
    echo "eucKR EUC-KR"
    echo "eucTW EUC-TW"
    echo "hp15CN GB2312"
    #echo "ccdc ?" # what is this?
    echo "SJIS SHIFT_JIS"
    echo "utf8 UTF-8"
    ;;
  irix*)
    echo "ISO8859-1 ISO-8859-1"
    echo "ISO8859-2 ISO-8859-2"
    echo "ISO8859-5 ISO-8859-5"
    echo "ISO8859-7 ISO-8859-7"
    echo "ISO8859-9 ISO-8859-9"
    echo "eucCN GB2312"
    echo "eucJP EUC-JP"
    echo "eucKR EUC-KR"
    echo "eucTW EUC-TW"
    ;;
  osf*)
    echo "ISO8859-1 ISO-8859-1"
    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-8 ISO-8859-8"
    echo "ISO8859-9 ISO-8859-9"
    echo "ISO8859-15 ISO-8859-15"
    echo "cp850 CP850"
    echo "big5 BIG5"
    echo "dechanyu DEC-HANYU"
    echo "dechanzi GB2312"
    echo "deckanji DEC-KANJI"
    echo "deckorean EUC-KR"
    echo "eucJP EUC-JP"
    echo "eucKR EUC-KR"
    echo "eucTW EUC-TW"
    echo "GBK GBK"
    echo "KSC5601 CP949"
    echo "sdeckanji EUC-JP"
    echo "SJIS SHIFT_JIS"
    echo "TACTIS TIS-620"
    echo "UTF-8 UTF-8"
    ;;
  solaris*)
    echo "646 ASCII"
    echo "ISO8859-1 ISO-8859-1"
    echo "ISO8859-2 ISO-8859-2"
    echo "ISO8859-3 ISO-8859-3"
    echo "ISO8859-4 ISO-8859-4"
    echo "ISO8859-5 ISO-8859-5"
    echo "ISO8859-6 ISO-8859-6"
    echo "ISO8859-7 ISO-8859-7"
    echo "ISO8859-8 ISO-8859-8"
    echo "ISO8859-9 ISO-8859-9"
    echo "ISO8859-15 ISO-8859-15"
    echo "koi8-r KOI8-R"
    echo "ansi-1251 CP1251"
    echo "BIG5 BIG5"
    echo "Big5-HKSCS BIG5-HKSCS"
    echo "gb2312 GB2312"
    echo "GBK GBK"
    echo "GB18030 GB18030"
    echo "cns11643 EUC-TW"
    echo "5601 EUC-KR"
    echo "ko_KR.johap92 JOHAB"
    echo "eucJP EUC-JP"
    echo "PCK SHIFT_JIS"
    echo "TIS620.2533 TIS-620"
    #echo "sun_eu_greek ?" # what is this?
    echo "UTF-8 UTF-8"
    ;;
  freebsd*)
    # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
    # localcharset.c falls back to using the full locale name
    # from the environment variables.
    echo "C ASCII"
    echo "US-ASCII ASCII"
    for l in la_LN lt_LN; do
      echo "$l.ASCII ASCII"
    done
    for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
             fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
             lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
      echo "$l.ISO_8859-1 ISO-8859-1"
      echo "$l.DIS_8859-15 ISO-8859-15"
    done
    for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
      echo "$l.ISO_8859-2 ISO-8859-2"
    done
    for l in la_LN lt_LT; do
      echo "$l.ISO_8859-4 ISO-8859-4"
    done
    for l in ru_RU ru_SU; do
      echo "$l.KOI8-R KOI8-R"
      echo "$l.ISO_8859-5 ISO-8859-5"
      echo "$l.CP866 CP866"
    done
    echo "uk_UA.KOI8-U KOI8-U"
    echo "zh_TW.BIG5 BIG5"
    echo "zh_TW.Big5 BIG5"
    echo "zh_CN.EUC GB2312"
    echo "ja_JP.EUC EUC-JP"
    echo "ja_JP.SJIS SHIFT_JIS"
    echo "ja_JP.Shift_JIS SHIFT_JIS"
    echo "ko_KR.EUC EUC-KR"
    ;;
  netbsd*)
    echo "646 ASCII"
    echo "ISO8859-1 ISO-8859-1"
    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"
    echo "eucKR EUC-KR"
    echo "eucTW EUC-TW"
    echo "BIG5 BIG5"
    echo "SJIS SHIFT_JIS"
    ;;
  openbsd*)
    echo "646 ASCII"
    echo "ISO8859-1 ISO-8859-1"
    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"
    ;;
  darwin[56]*)
    # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
    # localcharset.c falls back to using the full locale name
    # from the environment variables.
    echo "C ASCII"
    for l in en_AU en_CA en_GB en_US la_LN; do
      echo "$l.US-ASCII ASCII"
    done
    for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
             fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
             nl_NL no_NO pt_PT sv_SE; do
      echo "$l ISO-8859-1"
      echo "$l.ISO8859-1 ISO-8859-1"
      echo "$l.ISO8859-15 ISO-8859-15"
    done
    for l in la_LN; do
      echo "$l.ISO8859-1 ISO-8859-1"
      echo "$l.ISO8859-15 ISO-8859-15"
    done
    for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
      echo "$l.ISO8859-2 ISO-8859-2"
    done
    for l in la_LN lt_LT; do
      echo "$l.ISO8859-4 ISO-8859-4"
    done
    for l in ru_RU; do
      echo "$l.KOI8-R KOI8-R"
      echo "$l.ISO8859-5 ISO-8859-5"
      echo "$l.CP866 CP866"
    done
    for l in bg_BG; do
      echo "$l.CP1251 CP1251"
    done
    echo "uk_UA.KOI8-U KOI8-U"
    echo "zh_TW.BIG5 BIG5"
    echo "zh_TW.Big5 BIG5"
    echo "zh_CN.EUC GB2312"
    echo "ja_JP.EUC EUC-JP"
    echo "ja_JP.SJIS SHIFT_JIS"
    echo "ko_KR.EUC EUC-KR"
    ;;
  darwin*)
    # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
    # useless:
    # - It returns the empty string when LANG is set to a locale of the
    #   form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
    #   LC_CTYPE file.
    # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
    #   the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
    # - The documentation says:
    #     "... all code that calls BSD system routines should ensure
    #      that the const *char parameters of these routines are in UTF-8
    #      encoding. All BSD system functions expect their string
    #      parameters to be in UTF-8 encoding and nothing else."
    #   It also says
    #     "An additional caveat is that string parameters for files,
    #      paths, and other file-system entities must be in canonical
    #      UTF-8. In a canonical UTF-8 Unicode string, all decomposable
    #      characters are decomposed ..."
    #   but this is not true: You can pass non-decomposed UTF-8 strings
    #   to file system functions, and it is the OS which will convert
    #   them to decomposed UTF-8 before accessing the file system.
    # - The Apple Terminal application displays UTF-8 by default.
    # - However, other applications are free to use different encodings:
    #   - xterm uses ISO-8859-1 by default.
    #   - TextEdit uses MacRoman by default.
    # We prefer UTF-8 over decomposed UTF-8-MAC because one should
    # minimize the use of decomposed Unicode. Unfortunately, through the
    # Darwin file system, decomposed UTF-8 strings are leaked into user
    # space nevertheless.
    # Then there are also the locales with encodings other than US-ASCII
    # and UTF-8. These locales can be occasionally useful to users (e.g.
    # when grepping through ISO-8859-1 encoded text files), when all their
    # file names are in US-ASCII.
    echo "ISO8859-1 ISO-8859-1"
    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-9 ISO-8859-9"
    echo "ISO8859-13 ISO-8859-13"
    echo "ISO8859-15 ISO-8859-15"
    echo "KOI8-R KOI8-R"
    echo "KOI8-U KOI8-U"
    echo "CP866 CP866"
    echo "CP949 CP949"
    echo "CP1131 CP1131"
    echo "CP1251 CP1251"
    echo "eucCN GB2312"
    echo "GB2312 GB2312"
    echo "eucJP EUC-JP"
    echo "eucKR EUC-KR"
    echo "Big5 BIG5"
    echo "Big5HKSCS BIG5-HKSCS"
    echo "GBK GBK"
    echo "GB18030 GB18030"
    echo "SJIS SHIFT_JIS"
    echo "ARMSCII-8 ARMSCII-8"
    echo "PT154 PT154"
    #echo "ISCII-DEV ?"
    echo "* UTF-8"
    ;;
  beos* | haiku*)
    # BeOS and Haiku have a single locale, and it has UTF-8 encoding.
    echo "* UTF-8"
    ;;
  msdosdjgpp*)
    # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
    # localcharset.c falls back to using the full locale name
    # from the environment variables.
    echo "#"
    echo "# The encodings given here may not all be correct."
    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 <juan.guerrero@gmx.de>"
    echo "# and Bruno Haible <bruno@clisp.org>."
    echo "#"
    echo "C ASCII"
    # ISO-8859-1 languages
    echo "ca CP850"
    echo "ca_ES CP850"
    echo "da CP865"    # not CP850 ??
    echo "da_DK CP865" # not CP850 ??
    echo "de CP850"
    echo "de_AT CP850"
    echo "de_CH CP850"
    echo "de_DE CP850"
    echo "en CP850"
    echo "en_AU CP850" # not CP437 ??
    echo "en_CA CP850"
    echo "en_GB CP850"
    echo "en_NZ CP437"
    echo "en_US CP437"
    echo "en_ZA CP850" # not CP437 ??
    echo "es CP850"
    echo "es_AR CP850"
    echo "es_BO CP850"
    echo "es_CL CP850"
    echo "es_CO CP850"
    echo "es_CR CP850"
    echo "es_CU CP850"
    echo "es_DO CP850"
    echo "es_EC CP850"
    echo "es_ES CP850"
    echo "es_GT CP850"
    echo "es_HN CP850"
    echo "es_MX CP850"
    echo "es_NI CP850"
    echo "es_PA CP850"
    echo "es_PY CP850"
    echo "es_PE CP850"
    echo "es_SV CP850"
    echo "es_UY CP850"
    echo "es_VE CP850"
    echo "et CP850"
    echo "et_EE CP850"
    echo "eu CP850"
    echo "eu_ES CP850"
    echo "fi CP850"
    echo "fi_FI CP850"
    echo "fr CP850"
    echo "fr_BE CP850"
    echo "fr_CA CP850"
    echo "fr_CH CP850"
    echo "fr_FR CP850"
    echo "ga CP850"
    echo "ga_IE CP850"
    echo "gd CP850"
    echo "gd_GB CP850"
    echo "gl CP850"
    echo "gl_ES CP850"
    echo "id CP850"    # not CP437 ??
    echo "id_ID CP850" # not CP437 ??
    echo "is CP861"    # not CP850 ??
    echo "is_IS CP861" # not CP850 ??
    echo "it CP850"
    echo "it_CH CP850"
    echo "it_IT CP850"
    echo "lt CP775"
    echo "lt_LT CP775"
    echo "lv CP775"
    echo "lv_LV CP775"
    echo "nb CP865"    # not CP850 ??
    echo "nb_NO CP865" # not CP850 ??
    echo "nl CP850"
    echo "nl_BE CP850"
    echo "nl_NL CP850"
    echo "nn CP865"    # not CP850 ??
    echo "nn_NO CP865" # not CP850 ??
    echo "no CP865"    # not CP850 ??
    echo "no_NO CP865" # not CP850 ??
    echo "pt CP850"
    echo "pt_BR CP850"
    echo "pt_PT CP850"
    echo "sv CP850"
    echo "sv_SE CP850"
    # ISO-8859-2 languages
    echo "cs CP852"
    echo "cs_CZ CP852"
    echo "hr CP852"
    echo "hr_HR CP852"
    echo "hu CP852"
    echo "hu_HU CP852"
    echo "pl CP852"
    echo "pl_PL CP852"
    echo "ro CP852"
    echo "ro_RO CP852"
    echo "sk CP852"
    echo "sk_SK CP852"
    echo "sl CP852"
    echo "sl_SI CP852"
    echo "sq CP852"
    echo "sq_AL CP852"
    echo "sr CP852"    # CP852 or CP866 or CP855 ??
    echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
    echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
    # ISO-8859-3 languages
    echo "mt CP850"
    echo "mt_MT CP850"
    # ISO-8859-5 languages
    echo "be CP866"
    echo "be_BE CP866"
    echo "bg CP866"    # not CP855 ??
    echo "bg_BG CP866" # not CP855 ??
    echo "mk CP866"    # not CP855 ??
    echo "mk_MK CP866" # not CP855 ??
    echo "ru CP866"
    echo "ru_RU CP866"
    echo "uk CP1125"
    echo "uk_UA CP1125"
    # ISO-8859-6 languages
    echo "ar CP864"
    echo "ar_AE CP864"
    echo "ar_DZ CP864"
    echo "ar_EG CP864"
    echo "ar_IQ CP864"
    echo "ar_IR CP864"
    echo "ar_JO CP864"
    echo "ar_KW CP864"
    echo "ar_MA CP864"
    echo "ar_OM CP864"
    echo "ar_QA CP864"
    echo "ar_SA CP864"
    echo "ar_SY CP864"
    # ISO-8859-7 languages
    echo "el CP869"
    echo "el_GR CP869"
    # ISO-8859-8 languages
    echo "he CP862"
    echo "he_IL CP862"
    # ISO-8859-9 languages
    echo "tr CP857"
    echo "tr_TR CP857"
    # Japanese
    echo "ja CP932"
    echo "ja_JP CP932"
    # Chinese
    echo "zh_CN GBK"
    echo "zh_TW CP950" # not CP938 ??
    # Korean
    echo "kr CP949"    # not CP934 ??
    echo "kr_KR CP949" # not CP934 ??
    # Thai
    echo "th CP874"
    echo "th_TH CP874"
    # Other
    echo "eo CP850"
    echo "eo_EO CP850"
    ;;
esac

repo_name: mthl/texinfo

license: mit


code:
/* dirname.c -- return all but the last element in a file name

   Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2017 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */

#include <config.h>

#include "dirname.h"

#include <stdlib.h>
#include <string.h>

/* Return the length of the prefix of FILE that will be used by
   dir_name.  If FILE is in the working directory, this returns zero
   even though 'dir_name (FILE)' will return ".".  Works properly even
   if there are trailing slashes (by effectively ignoring them).  */

size_t
dir_len (char const *file)
{
  size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
  size_t length;

  /* Advance prefix_length beyond important leading slashes.  */
  prefix_length += (prefix_length != 0
                    ? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
                       && ISSLASH (file[prefix_length]))
                    : (ISSLASH (file[0])
                       ? ((DOUBLE_SLASH_IS_DISTINCT_ROOT
                           && ISSLASH (file[1]) && ! ISSLASH (file[2])
                           ? 2 : 1))
                       : 0));

  /* Strip the basename and any redundant slashes before it.  */
  for (length = last_component (file) - file;
       prefix_length < length; length--)
    if (! ISSLASH (file[length - 1]))
      break;
  return length;
}

/* In general, we can't use the builtin 'dirname' function if available,
   since it has different meanings in different environments.
   In some environments the builtin 'dirname' modifies its argument.

   Return the leading directories part of FILE, allocated with malloc.
   Works properly even if there are trailing slashes (by effectively
   ignoring them).  Return NULL on failure.

   If lstat (FILE) would succeed, then { chdir (dir_name (FILE));
   lstat (base_name (FILE)); } will access the same file.  Likewise,
   if the sequence { chdir (dir_name (FILE));
   rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE
   to "foo" in the same directory FILE was in.  */

char *
mdir_name (char const *file)
{
  size_t length = dir_len (file);
  bool append_dot = (length == 0
                     || (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
                         && length == FILE_SYSTEM_PREFIX_LEN (file)
                         && file[2] != '\0' && ! ISSLASH (file[2])));
  char *dir = malloc (length + append_dot + 1);
  if (!dir)
    return NULL;
  memcpy (dir, file, length);
  if (append_dot)
    dir[length++] = '.';
  dir[length] = '\0';
  return dir;
}


code:
/*  Take file names apart into directory and base names.

    Copyright (C) 1998, 2001, 2003-2006, 2009-2017 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */

#ifndef DIRNAME_H_
# define DIRNAME_H_ 1

# include <stdbool.h>
# include <stddef.h>
# include "dosname.h"

# ifndef DIRECTORY_SEPARATOR
#  define DIRECTORY_SEPARATOR '/'
# endif

# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
#  define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
# endif

#ifdef __cplusplus
extern "C" {
#endif

# if GNULIB_DIRNAME
char *base_name (char const *file);
char *dir_name (char const *file);
# endif

char *mdir_name (char const *file);
size_t base_len (char const *file) _GL_ATTRIBUTE_PURE;
size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
char *last_component (char const *file) _GL_ATTRIBUTE_PURE;

bool strip_trailing_slashes (char *file);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* not DIRNAME_H_ */


code:
/* File names on MS-DOS/Windows systems.

   Copyright (C) 2000-2001, 2004-2006, 2009-2017 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.

   From Paul Eggert and Jim Meyering.  */

#ifndef _DOSNAME_H
#define _DOSNAME_H

#if (defined _WIN32 || defined __WIN32__ ||     \
     defined __MSDOS__ || defined __CYGWIN__ || \
     defined __EMX__ || defined __DJGPP__)
   /* This internal macro assumes ASCII, but all hosts that support drive
      letters use ASCII.  */
# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a'  \
                              <= 'z' - 'a')
# define FILE_SYSTEM_PREFIX_LEN(Filename) \
          (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
# ifndef __CYGWIN__
#  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
# endif
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
#else
# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
# define ISSLASH(C) ((C) == '/')
#endif

#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
#endif

#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
#  define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
# else
#  define IS_ABSOLUTE_FILE_NAME(F)                              \
     (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
#endif
#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))

#endif /* DOSNAME_H_ */


code:
/* A POSIX-like <errno.h>.

   Copyright (C) 2008-2017 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 3, 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, see <http://www.gnu.org/licenses/>.  */

#ifndef _@GUARD_PREFIX@_ERRNO_H

#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@

/* The include_next requires a split double-inclusion guard.  */
#@INCLUDE_NEXT@ @NEXT_ERRNO_H@

#ifndef _@GUARD_PREFIX@_ERRNO_H
#define _@GUARD_PREFIX@_ERRNO_H

/* On native Windows platforms, many macros are not defined.  */
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__

/* These are the same values as defined by MSVC 10, for interoperability.  */

#  ifndef ENOMSG
#   define ENOMSG    122
#   define GNULIB_defined_ENOMSG 1
#  endif

#  ifndef EIDRM
#   define EIDRM     111
#   define GNULIB_defined_EIDRM 1
#  endif

#  ifndef ENOLINK
#   define ENOLINK   121
#   define GNULIB_defined_ENOLINK 1
#  endif

#  ifndef EPROTO
#   define EPROTO    134
#   define GNULIB_defined_EPROTO 1
#  endif

#  ifndef EBADMSG
#   define EBADMSG   104
#   define GNULIB_defined_EBADMSG 1
#  endif

#  ifndef EOVERFLOW
#   define EOVERFLOW 132
#   define GNULIB_defined_EOVERFLOW 1
#  endif

#  ifndef ENOTSUP
#   define ENOTSUP   129
#   define GNULIB_defined_ENOTSUP 1
#  endif

#  ifndef ENETRESET
#   define ENETRESET 117
#   define GNULIB_defined_ENETRESET 1
#  endif

#  ifndef ECONNABORTED
#   define ECONNABORTED 106
#   define GNULIB_defined_ECONNABORTED 1
#  endif

#  ifndef ECANCELED
#   define ECANCELED 105
#   define GNULIB_defined_ECANCELED 1
#  endif

#  ifndef EOWNERDEAD
#   define EOWNERDEAD 133
#   define GNULIB_defined_EOWNERDEAD 1
#  endif

#  ifndef ENOTRECOVERABLE
#   define ENOTRECOVERABLE 127
#   define GNULIB_defined_ENOTRECOVERABLE 1
#  endif

#  ifndef EINPROGRESS
#   define EINPROGRESS     112
#   define EALREADY        103
#   define ENOTSOCK        128
#   define EDESTADDRREQ    109
#   define EMSGSIZE        115
#   define EPROTOTYPE      136
#   define ENOPROTOOPT     123
#   define EPROTONOSUPPORT 135
#   define EOPNOTSUPP      130
#   define EAFNOSUPPORT    102
#   define EADDRINUSE      100
#   define EADDRNOTAVAIL   101
#   define ENETDOWN        116
#   define ENETUNREACH     118
#   define ECONNRESET      108
#   define ENOBUFS         119
#   define EISCONN         113
#   define ENOTCONN        126
#   define ETIMEDOUT       138
#   define ECONNREFUSED    107
#   define ELOOP           114
#   define EHOSTUNREACH    110
#   define EWOULDBLOCK     140
#   define GNULIB_defined_ESOCK 1
#  endif

#  ifndef ETXTBSY
#   define ETXTBSY         139
#   define ENODATA         120  /* not required by POSIX */
#   define ENOSR           124  /* not required by POSIX */
#   define ENOSTR          125  /* not required by POSIX */
#   define ETIME           137  /* not required by POSIX */
#   define EOTHER          131  /* not required by POSIX */
#   define GNULIB_defined_ESTREAMS 1
#  endif

/* These are intentionally the same values as the WSA* error numbers, defined
   in <winsock2.h>.  */
#  define ESOCKTNOSUPPORT 10044  /* not required by POSIX */
#  define EPFNOSUPPORT    10046  /* not required by POSIX */
#  define ESHUTDOWN       10058  /* not required by POSIX */
#  define ETOOMANYREFS    10059  /* not required by POSIX */
#  define EHOSTDOWN       10064  /* not required by POSIX */
#  define EPROCLIM        10067  /* not required by POSIX */
#  define EUSERS          10068  /* not required by POSIX */
#  define EDQUOT          10069
#  define ESTALE          10070
#  define EREMOTE         10071  /* not required by POSIX */
#  define GNULIB_defined_EWINSOCK 1

# endif

/* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros
   EMULTIHOP, ENOLINK, EOVERFLOW are not defined.  */
# if @EMULTIHOP_HIDDEN@
#  define EMULTIHOP @EMULTIHOP_VALUE@
#  define GNULIB_defined_EMULTIHOP 1
# endif
# if @ENOLINK_HIDDEN@
#  define ENOLINK   @ENOLINK_VALUE@
#  define GNULIB_defined_ENOLINK 1
# endif
# if @EOVERFLOW_HIDDEN@
#  define EOVERFLOW @EOVERFLOW_VALUE@
#  define GNULIB_defined_EOVERFLOW 1
# endif

/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
   EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
   Likewise, on NonStop Kernel, EDQUOT is not defined.
   Define them here.  Values >= 2000 seem safe to use: Solaris ESTALE = 151,
   HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133.

   Note: When one of these systems defines some of these macros some day,
   binaries will have to be recompiled so that they recognizes the new
   errno values from the system.  */

# ifndef ENOMSG
#  define ENOMSG    2000
#  define GNULIB_defined_ENOMSG 1
# endif

# ifndef EIDRM
#  define EIDRM     2001
#  define GNULIB_defined_EIDRM 1
# endif

# ifndef ENOLINK
#  define ENOLINK   2002
#  define GNULIB_defined_ENOLINK 1
# endif

# ifndef EPROTO
#  define EPROTO    2003
#  define GNULIB_defined_EPROTO 1
# endif

# ifndef EMULTIHOP
#  define EMULTIHOP 2004
#  define GNULIB_defined_EMULTIHOP 1
# endif

# ifndef EBADMSG
#  define EBADMSG   2005
#  define GNULIB_defined_EBADMSG 1
# endif

# ifndef EOVERFLOW
#  define EOVERFLOW 2006
#  define GNULIB_defined_EOVERFLOW 1
# endif

# ifndef ENOTSUP
#  define ENOTSUP   2007
#  define GNULIB_defined_ENOTSUP 1
# endif

# ifndef ENETRESET
#  define ENETRESET 2011
#  define GNULIB_defined_ENETRESET 1
# endif

# ifndef ECONNABORTED
#  define ECONNABORTED 2012
#  define GNULIB_defined_ECONNABORTED 1
# endif

# ifndef ESTALE
#  define ESTALE    2009
#  define GNULIB_defined_ESTALE 1
# endif

# ifndef EDQUOT
#  define EDQUOT 2010
#  define GNULIB_defined_EDQUOT 1
# endif

# ifndef ECANCELED
#  define ECANCELED 2008
#  define GNULIB_defined_ECANCELED 1
# endif

/* On many platforms, the macros EOWNERDEAD and ENOTRECOVERABLE are not
   defined.  */

# ifndef EOWNERDEAD
#  if defined __sun
    /* Use the same values as defined for Solaris >= 8, for
       interoperability.  */
#   define EOWNERDEAD      58
#   define ENOTRECOVERABLE 59
#  elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
    /* We have a conflict here: pthreads-win32 defines these values
       differently than MSVC 10.  It's hairy to decide which one to use.  */
#   if defined __MINGW32__ && !defined USE_WINDOWS_THREADS
     /* Use the same values as defined by pthreads-win32, for
        interoperability.  */
#    define EOWNERDEAD      43
#    define ENOTRECOVERABLE 44
#   else
     /* Use the same values as defined by MSVC 10, for
        interoperability.  */
#    define EOWNERDEAD      133
#    define ENOTRECOVERABLE 127
#   endif
#  else
#   define EOWNERDEAD      2013
#   define ENOTRECOVERABLE 2014
#  endif
#  define GNULIB_defined_EOWNERDEAD 1
#  define GNULIB_defined_ENOTRECOVERABLE 1
# endif

# ifndef EILSEQ
#  define EILSEQ 2015
#  define GNULIB_defined_EILSEQ 1
# endif

#endif /* _@GUARD_PREFIX@_ERRNO_H */
#endif /* _@GUARD_PREFIX@_ERRNO_H */


code:
/* Error handler for noninteractive utilities
   Copyright (C) 1990-1998, 2000-2007, 2009-2017 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */

/* Written by David MacKenzie <djm@gnu.ai.mit.edu>.  */

#if !_LIBC
# include <config.h>
#endif

#include "error.h"

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if !_LIBC && ENABLE_NLS
# include "gettext.h"
# define _(msgid) gettext (msgid)
#endif

#ifdef _LIBC
# include <libintl.h>
# include <stdbool.h>
# include <stdint.h>
# include <wchar.h>
# define mbsrtowcs __mbsrtowcs
# define USE_UNLOCKED_IO 0
# define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b)
# define _GL_ARG_NONNULL(a)
#else
# include "getprogname.h"
#endif

#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif

#ifndef _
# define _(String) String
#endif

/* If NULL, error will flush stdout, then print on stderr the program
   name, a colon and a space.  Otherwise, error will call this
   function without parameters instead.  */
void (*error_print_progname) (void);

/* This variable is incremented each time 'error' is called.  */
unsigned int error_message_count;

#ifdef _LIBC
/* In the GNU C library, there is a predefined variable for this.  */

# 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.
   Instead make it a weak alias.  */
extern void __error (int status, int errnum, const char *message, ...)
     __attribute__ ((__format__ (__printf__, 3, 4)));
extern void __error_at_line (int status, int errnum, const char *file_name,
                             unsigned int line_number, const char *message,
                             ...)
     __attribute__ ((__format__ (__printf__, 5, 6)));
# define error __error
# define error_at_line __error_at_line

# include <libio/iolibio.h>
# define fflush(s) _IO_fflush (s)
# undef putc
# define putc(c, fp) _IO_putc (c, fp)

# include <bits/libc-lock.h>

#else /* not _LIBC */

# include <fcntl.h>
# include <unistd.h>

# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* Get declarations of the native Windows API functions.  */
#  define WIN32_LEAN_AND_MEAN
#  include <windows.h>
/* Get _get_osfhandle.  */
#  include "msvc-nothrow.h"
# endif

/* The gnulib override of fcntl is not needed in this file.  */
# undef fcntl

# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R)
#  ifndef HAVE_DECL_STRERROR_R
"this configure-time declaration test was not run"
#  endif
#  if STRERROR_R_CHAR_P
char *strerror_r (int errnum, char *buf, size_t buflen);
#  else
int strerror_r (int errnum, char *buf, size_t buflen);
#  endif
# endif

#define program_name getprogname ()

# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r
#  define __strerror_r strerror_r
# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */
#endif  /* not _LIBC */

#if !_LIBC
/* Return non-zero if FD is open.  */
static int
is_open (int fd)
{
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
  /* On native Windows: The initial state of unassigned standard file
     descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
     There is no fcntl, and the gnulib replacement fcntl does not support
     F_GETFL.  */
  return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
# else
#  ifndef F_GETFL
#   error Please port fcntl to your platform
#  endif
  return 0 <= fcntl (fd, F_GETFL);
# endif
}
#endif

static void
flush_stdout (void)
{
#if !_LIBC
  int stdout_fd;

# if GNULIB_FREOPEN_SAFER
  /* Use of gnulib's freopen-safer module normally ensures that
       fileno (stdout) == 1
     whenever stdout is open.  */
  stdout_fd = STDOUT_FILENO;
# else
  /* POSIX states that fileno (stdout) after fclose is unspecified.  But in
     practice it is not a problem, because stdout is statically allocated and
     the fd of a FILE stream is stored as a field in its allocated memory.  */
  stdout_fd = fileno (stdout);
# endif
  /* POSIX states that fflush (stdout) after fclose is unspecified; it
     is safe in glibc, but not on all other platforms.  fflush (NULL)
     is always defined, but too draconian.  */
  if (0 <= stdout_fd && is_open (stdout_fd))
#endif
    fflush (stdout);
}

static void
print_errno_message (int errnum)
{
  char const *s;

#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R
  char errbuf[1024];
# if _LIBC || GNULIB_STRERROR_R_POSIX || STRERROR_R_CHAR_P
  s = __strerror_r (errnum, errbuf, sizeof errbuf);
# else
  if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
    s = errbuf;
  else
    s = 0;
# endif
#else
  s = strerror (errnum);
#endif

#if !_LIBC
  if (! s)
    s = _("Unknown system error");
#endif

#if _LIBC
  __fxprintf (NULL, ": %s", s);
#else
  fprintf (stderr, ": %s", s);
#endif
}

static void _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3))
error_tail (int status, int errnum, const char *message, va_list args)
{
#if _LIBC
  if (_IO_fwide (stderr, 0) > 0)
    {
      size_t len = strlen (message) + 1;
      wchar_t *wmessage = NULL;
      mbstate_t st;
      size_t res;
      const char *tmp;
      bool use_malloc = false;

      while (1)
        {
          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));
          tmp = message;

          res = mbsrtowcs (wmessage, &tmp, len, &st);
          if (res != len)
            break;

          if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 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 (use_malloc)
        free (wmessage);
    }
  else
#endif
    vfprintf (stderr, message, args);
  va_end (args);

  ++error_message_count;
  if (errnum)
    print_errno_message (errnum);
#if _LIBC
  __fxprintf (NULL, "\n");
#else
  putc ('\n', stderr);
#endif
  fflush (stderr);
  if (status)
    exit (status);
}

/* Print the program name and error message MESSAGE, which is a printf-style
   format string with optional args.
   If ERRNUM is nonzero, print its corresponding system error message.
   Exit with status STATUS if it is nonzero.  */
void
error (int status, int errnum, const char *message, ...)
{
  va_list args;

#if defined _LIBC && defined __libc_ptf_call
  /* We do not want this call to be cut short by a thread
     cancellation.  Therefore disable cancellation for now.  */
  int state = PTHREAD_CANCEL_ENABLE;
  __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
                   0);
#endif

  flush_stdout ();
#ifdef _LIBC
  _IO_flockfile (stderr);
#endif
  if (error_print_progname)
    (*error_print_progname) ();
  else
    {
#if _LIBC
      __fxprintf (NULL, "%s: ", program_name);
#else
      fprintf (stderr, "%s: ", program_name);
#endif
    }

  va_start (args, message);
  error_tail (status, errnum, message, args);

#ifdef _LIBC
  _IO_funlockfile (stderr);
# ifdef __libc_ptf_call
  __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
# endif
#endif
}

/* Sometimes we want to have at most one error per line.  This
   variable controls whether this mode is selected or not.  */
int error_one_per_line;

void
error_at_line (int status, int errnum, const char *file_name,
               unsigned int line_number, const char *message, ...)
{
  va_list args;

  if (error_one_per_line)
    {
      static const char *old_file_name;
      static unsigned int old_line_number;

      if (old_line_number == line_number
          && (file_name == old_file_name
              || (old_file_name != NULL
                  && file_name != NULL
                  && strcmp (old_file_name, file_name) == 0)))

        /* Simply return and print nothing.  */
        return;

      old_file_name = file_name;
      old_line_number = line_number;
    }

#if defined _LIBC && defined __libc_ptf_call
  /* We do not want this call to be cut short by a thread
     cancellation.  Therefore disable cancellation for now.  */
  int state = PTHREAD_CANCEL_ENABLE;
  __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
                   0);
#endif

  flush_stdout ();
#ifdef _LIBC
  _IO_flockfile (stderr);
#endif
  if (error_print_progname)
    (*error_print_progname) ();
  else
    {
#if _LIBC
      __fxprintf (NULL, "%s:", program_name);
#else
      fprintf (stderr, "%s:", program_name);
#endif
    }

#if _LIBC
  __fxprintf (NULL, file_name != NULL ? "%s:%u: " : " ",
              file_name, line_number);
#else
  fprintf (stderr, file_name != NULL ? "%s:%u: " : " ",
           file_name, line_number);
#endif

  va_start (args, message);
  error_tail (status, errnum, message, args);

#ifdef _LIBC
  _IO_funlockfile (stderr);
# ifdef __libc_ptf_call
  __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
# endif
#endif
}

#ifdef _LIBC
/* Make the weak alias.  */
# undef error
# undef error_at_line
weak_alias (__error, error)
weak_alias (__error_at_line, error_at_line)
#endif


code:
/* Declaration for error-reporting function
   Copyright (C) 1995-1997, 2003, 2006, 2008-2017 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */

#ifndef _ERROR_H
#define _ERROR_H 1

/* The __attribute__ feature is available in gcc versions 2.5 and later.
   The __-protected variants of the attributes 'format' and 'printf' are
   accepted by gcc versions 2.6.4 (effectively 2.7) and later.
   We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
   gnulib and libintl do '#define printf __printf__' when they override
   the 'printf' function.  */
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
#else
# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
#endif

/* On mingw, the flavor of printf depends on whether the extensions module
 * is in use; the check for <stdio.h> determines the witness macro.  */
#ifndef _GL_ATTRIBUTE_SPEC_PRINTF
# if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
#  define _GL_ATTRIBUTE_SPEC_PRINTF __gnu_printf__
# else
#  define _GL_ATTRIBUTE_SPEC_PRINTF __printf__
# endif
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Print a message with 'fprintf (stderr, FORMAT, ...)';
   if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
   If STATUS is nonzero, terminate the program with 'exit (STATUS)'.  */

extern void error (int __status, int __errnum, const char *__format, ...)
     _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 3, 4));

extern void error_at_line (int __status, int __errnum, const char *__fname,
                           unsigned int __lineno, const char *__format, ...)
     _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 5, 6));

/* If NULL, error will flush stdout, then print on stderr the program
   name, a colon and a space.  Otherwise, error will call this
   function without parameters instead.  */
extern void (*error_print_progname) (void);

/* This variable is incremented each time 'error' is called.  */
extern unsigned int error_message_count;

/* Sometimes we want to have at most one error per line.  This
   variable controls whether this mode is selected or not.  */
extern int error_one_per_line;

#ifdef __cplusplus
}
#endif

#endif /* error.h */


code:
/* Failure exit status

   Copyright (C) 2002-2003, 2005-2007, 2009-2017 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */

#include <config.h>

#include "exitfail.h"

#include <stdlib.h>

int volatile exit_failure = EXIT_FAILURE;


code:
/* Failure exit status

   Copyright (C) 2002, 2009-2017 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */

extern int volatile exit_failure;


code:
/* Supplemental information about the floating-point formats.
   Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
   Written by Bruno Haible <bruno@clisp.org>, 2007.

   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 3, 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, see <http://www.gnu.org/licenses/>.  */

#ifndef _FLOATPLUS_H
#define _FLOATPLUS_H

#include <float.h>
#include <limits.h>

/* Number of bits in the mantissa of a floating-point number, including the
   "hidden bit".  */
#if FLT_RADIX == 2
# define FLT_MANT_BIT FLT_MANT_DIG
# define DBL_MANT_BIT DBL_MANT_DIG
# define LDBL_MANT_BIT LDBL_MANT_DIG
#elif FLT_RADIX == 4
# define FLT_MANT_BIT (FLT_MANT_DIG * 2)
# define DBL_MANT_BIT (DBL_MANT_DIG * 2)
# define LDBL_MANT_BIT (LDBL_MANT_DIG * 2)
#elif FLT_RADIX == 16
# define FLT_MANT_BIT (FLT_MANT_DIG * 4)
# define DBL_MANT_BIT (DBL_MANT_DIG * 4)
# define LDBL_MANT_BIT (LDBL_MANT_DIG * 4)
#endif

/* Bit mask that can be used to mask the exponent, as an unsigned number.  */
#define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7)
#define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
#define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7)

/* Number of bits used for the exponent of a floating-point number, including
   the exponent's sign.  */
#define FLT_EXP_BIT \
  (FLT_EXP_MASK < 0x100 ? 8 : \
   FLT_EXP_MASK < 0x200 ? 9 : \
   FLT_EXP_MASK < 0x400 ? 10 : \
   FLT_EXP_MASK < 0x800 ? 11 : \
   FLT_EXP_MASK < 0x1000 ? 12 : \
   FLT_EXP_MASK < 0x2000 ? 13 : \
   FLT_EXP_MASK < 0x4000 ? 14 : \
   FLT_EXP_MASK < 0x8000 ? 15 : \
   FLT_EXP_MASK < 0x10000 ? 16 : \
   FLT_EXP_MASK < 0x20000 ? 17 : \
   FLT_EXP_MASK < 0x40000 ? 18 : \
   FLT_EXP_MASK < 0x80000 ? 19 : \
   FLT_EXP_MASK < 0x100000 ? 20 : \
   FLT_EXP_MASK < 0x200000 ? 21 : \
   FLT_EXP_MASK < 0x400000 ? 22 : \
   FLT_EXP_MASK < 0x800000 ? 23 : \
   FLT_EXP_MASK < 0x1000000 ? 24 : \
   FLT_EXP_MASK < 0x2000000 ? 25 : \
   FLT_EXP_MASK < 0x4000000 ? 26 : \
   FLT_EXP_MASK < 0x8000000 ? 27 : \
   FLT_EXP_MASK < 0x10000000 ? 28 : \
   FLT_EXP_MASK < 0x20000000 ? 29 : \
   FLT_EXP_MASK < 0x40000000 ? 30 : \
   FLT_EXP_MASK <= 0x7fffffff ? 31 : \
   32)
#define DBL_EXP_BIT \
  (DBL_EXP_MASK < 0x100 ? 8 : \
   DBL_EXP_MASK < 0x200 ? 9 : \
   DBL_EXP_MASK < 0x400 ? 10 : \
   DBL_EXP_MASK < 0x800 ? 11 : \
   DBL_EXP_MASK < 0x1000 ? 12 : \
   DBL_EXP_MASK < 0x2000 ? 13 : \
   DBL_EXP_MASK < 0x4000 ? 14 : \
   DBL_EXP_MASK < 0x8000 ? 15 : \
   DBL_EXP_MASK < 0x10000 ? 16 : \
   DBL_EXP_MASK < 0x20000 ? 17 : \
   DBL_EXP_MASK < 0x40000 ? 18 : \
   DBL_EXP_MASK < 0x80000 ? 19 : \
   DBL_EXP_MASK < 0x100000 ? 20 : \
   DBL_EXP_MASK < 0x200000 ? 21 : \
   DBL_EXP_MASK < 0x400000 ? 22 : \
   DBL_EXP_MASK < 0x800000 ? 23 : \
   DBL_EXP_MASK < 0x1000000 ? 24 : \
   DBL_EXP_MASK < 0x2000000 ? 25 : \
   DBL_EXP_MASK < 0x4000000 ? 26 : \
   DBL_EXP_MASK < 0x8000000 ? 27 : \
   DBL_EXP_MASK < 0x10000000 ? 28 : \
   DBL_EXP_MASK < 0x20000000 ? 29 : \
   DBL_EXP_MASK < 0x40000000 ? 30 : \
   DBL_EXP_MASK <= 0x7fffffff ? 31 : \
   32)
#define LDBL_EXP_BIT \
  (LDBL_EXP_MASK < 0x100 ? 8 : \
   LDBL_EXP_MASK < 0x200 ? 9 : \
   LDBL_EXP_MASK < 0x400 ? 10 : \
   LDBL_EXP_MASK < 0x800 ? 11 : \
   LDBL_EXP_MASK < 0x1000 ? 12 : \
   LDBL_EXP_MASK < 0x2000 ? 13 : \
   LDBL_EXP_MASK < 0x4000 ? 14 : \
   LDBL_EXP_MASK < 0x8000 ? 15 : \
   LDBL_EXP_MASK < 0x10000 ? 16 : \
   LDBL_EXP_MASK < 0x20000 ? 17 : \
   LDBL_EXP_MASK < 0x40000 ? 18 : \
   LDBL_EXP_MASK < 0x80000 ? 19 : \
   LDBL_EXP_MASK < 0x100000 ? 20 : \
   LDBL_EXP_MASK < 0x200000 ? 21 : \
   LDBL_EXP_MASK < 0x400000 ? 22 : \
   LDBL_EXP_MASK < 0x800000 ? 23 : \
   LDBL_EXP_MASK < 0x1000000 ? 24 : \
   LDBL_EXP_MASK < 0x2000000 ? 25 : \
   LDBL_EXP_MASK < 0x4000000 ? 26 : \
   LDBL_EXP_MASK < 0x8000000 ? 27 : \
   LDBL_EXP_MASK < 0x10000000 ? 28 : \
   LDBL_EXP_MASK < 0x20000000 ? 29 : \
   LDBL_EXP_MASK < 0x40000000 ? 30 : \
   LDBL_EXP_MASK <= 0x7fffffff ? 31 : \
   32)

/* Number of bits used for a floating-point number: the mantissa (not
   counting the "hidden bit", since it may or may not be explicit), the
   exponent, and the sign.  */
#define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1)
#define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1)
#define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1)

/* Number of bytes used for a floating-point number.
   This can be smaller than the 'sizeof'.  For example, on i386 systems,
   'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence
   LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but
   sizeof (long double) = 12 or = 16.  */
#define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
#define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
#define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)

/* Verify that SIZEOF_FLT <= sizeof (float) etc.  */
typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1];
typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1];
typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1];

#endif /* _FLOATPLUS_H */


code:
/* Auxiliary definitions for <float.h>.
   Copyright (C) 2011-2017 Free Software Foundation, Inc.
   Written by Bruno Haible <bruno@clisp.org>, 2011.

   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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */

#include <config.h>

/* Specification.  */
#include <float.h>

#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
const union gl_long_double_union gl_LDBL_MAX =
  { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } };
#elif defined __i386__
const union gl_long_double_union gl_LDBL_MAX =
  { { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } };
#else
/* This declaration is solely to ensure that after preprocessing
   this file is never empty.  */
typedef int dummy;
#endif


code:
/* A correct <float.h>.

   Copyright (C) 2007-2017 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */

#ifndef _@GUARD_PREFIX@_FLOAT_H

#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@

/* The include_next requires a split double-inclusion guard.  */
#@INCLUDE_NEXT@ @NEXT_FLOAT_H@

#ifndef _@GUARD_PREFIX@_FLOAT_H
#define _@GUARD_PREFIX@_FLOAT_H

/* 'long double' properties.  */

#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
/* Number of mantissa units, in base FLT_RADIX.  */
# undef LDBL_MANT_DIG
# define LDBL_MANT_DIG   64
/* Number of decimal digits that is sufficient for representing a number.  */
# undef LDBL_DIG
# define LDBL_DIG        18
/* x-1 where x is the smallest representable number > 1.  */
# undef LDBL_EPSILON
# define LDBL_EPSILON    1.0842021724855044340E-19L
/* Minimum e such that FLT_RADIX^(e-1) is a normalized number.  */
# undef LDBL_MIN_EXP
# define LDBL_MIN_EXP    (-16381)
/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number.  */
# undef LDBL_MAX_EXP
# define LDBL_MAX_EXP    16384
/* Minimum positive normalized number.  */
# undef LDBL_MIN
# define LDBL_MIN        3.3621031431120935063E-4932L
/* Maximum representable finite number.  */
# undef LDBL_MAX
# define LDBL_MAX        1.1897314953572317650E+4932L
/* Minimum e such that 10^e is in the range of normalized numbers.  */
# undef LDBL_MIN_10_EXP
# define LDBL_MIN_10_EXP (-4931)
/* Maximum e such that 10^e is in the range of representable finite numbers.  */
# undef LDBL_MAX_10_EXP
# define LDBL_MAX_10_EXP 4932
#endif

/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of
   precision in the compiler but 64 bits of precision at runtime.  See
   <http://lists.gnu.org/archive/html/bug-gnulib/2008-07/msg00063.html>.  */
#if defined __i386__ && defined __FreeBSD__
/* Number of mantissa units, in base FLT_RADIX.  */
# undef LDBL_MANT_DIG
# define LDBL_MANT_DIG   64
/* Number of decimal digits that is sufficient for representing a number.  */
# undef LDBL_DIG
# define LDBL_DIG        18
/* x-1 where x is the smallest representable number > 1.  */
# undef LDBL_EPSILON
# define LDBL_EPSILON 1.084202172485504434007452800869941711426e-19L /* 2^-63 */
/* Minimum e such that FLT_RADIX^(e-1) is a normalized number.  */
# undef LDBL_MIN_EXP
# define LDBL_MIN_EXP    (-16381)
/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number.  */
# undef LDBL_MAX_EXP
# define LDBL_MAX_EXP    16384
/* Minimum positive normalized number.  */
# undef LDBL_MIN
# define LDBL_MIN        3.3621031431120935E-4932L /* = 0x1p-16382L */
/* Maximum representable finite number.  */
# undef LDBL_MAX
/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }.
   But the largest literal that GCC allows us to write is
   0x0.fffffffffffff8p16384L = { 0xFFFFF800, 0xFFFFFFFF, 32766 }.
   So, define it like this through a reference to an external variable

     const unsigned int LDBL_MAX[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 32766 };
     extern const long double LDBL_MAX;

   Unfortunately, this is not a constant expression.  */
union gl_long_double_union
  {
    struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd;
    long double ld;
  };
extern const union gl_long_double_union gl_LDBL_MAX;
# define LDBL_MAX (gl_LDBL_MAX.ld)
/* Minimum e such that 10^e is in the range of normalized numbers.  */
# undef LDBL_MIN_10_EXP
# define LDBL_MIN_10_EXP (-4931)
/* Maximum e such that 10^e is in the range of representable finite numbers.  */
# undef LDBL_MAX_10_EXP
# define LDBL_MAX_10_EXP 4932
#endif

/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are
   wrong.
   On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong.  */
#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__
# undef LDBL_MIN_EXP
# define LDBL_MIN_EXP DBL_MIN_EXP
# undef LDBL_MIN_10_EXP
# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
# undef LDBL_MIN
# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
#endif
#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
# undef LDBL_MAX
/* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }.
   It is not easy to define:
     #define LDBL_MAX 1.79769313486231580793728971405302307166e308L
   is too small, whereas
     #define LDBL_MAX 1.79769313486231580793728971405302307167e308L
   is too large.  Apparently a bug in GCC decimal-to-binary conversion.
   Also, I can't get values larger than
     #define LDBL63 ((long double) (1ULL << 63))
     #define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
     #define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
     #define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
     #define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL)
   which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }.
   So, define it like this through a reference to an external variable

     const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL };
     extern const long double LDBL_MAX;

   or through a pointer cast

     #define LDBL_MAX \
       (*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL })

   Unfortunately, this is not a constant expression, and the latter expression
   does not work well when GCC is optimizing..  */
union gl_long_double_union
  {
    struct { double hi; double lo; } dd;
    long double ld;
  };
extern const union gl_long_double_union gl_LDBL_MAX;
# define LDBL_MAX (gl_LDBL_MAX.ld)
#endif

/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong.
   On IRIX 6.5, with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_EPSILON
   are wrong.  */
#if defined __sgi && (LDBL_MANT_DIG >= 106)
# undef LDBL_MANT_DIG
# define LDBL_MANT_DIG 106
# if defined __GNUC__
#  undef LDBL_MIN_EXP
#  define LDBL_MIN_EXP DBL_MIN_EXP
#  undef LDBL_MIN_10_EXP
#  define LDBL_MIN_10_EXP DBL_MIN_10_EXP
#  undef LDBL_MIN
#  define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
#  undef LDBL_EPSILON
#  define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */
# endif
#endif

#if @REPLACE_ITOLD@
/* Pull in a function that fixes the 'int' to 'long double' conversion
   of glibc 2.7.  */
extern
# ifdef __cplusplus
"C"
# endif
void _Qp_itoq (long double *, int);
static void (*_gl_float_fix_itold) (long double *, int) = _Qp_itoq;
#endif

#endif /* _@GUARD_PREFIX@_FLOAT_H */
#endif /* _@GUARD_PREFIX@_FLOAT_H */


code:
/* getopt-on-non-glibc compatibility macros.
   Copyright (C) 1989-2017 Free Software Foundation, Inc.
   This file is part of gnulib.
   Unlike most of the getopt implementation, it is NOT shared
   with the GNU C Library.

   gnulib 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 3 of
   the License, or (at your option) any later version.

   gnulib 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 gnulib; if not, see
   <http://www.gnu.org/licenses/>.  */

#ifndef _GETOPT_CDEFS_H
#define _GETOPT_CDEFS_H 1

/* This header should not be used directly; include getopt.h or
   unistd.h instead.  It does not have a protective #error, because
   the guard macro for getopt.h in gnulib is not fixed.  */

/* getopt-core.h and getopt-ext.h are shared with GNU libc, and expect
   a number of the internal macros supplied to GNU libc's headers by
   sys/cdefs.h.  Provide fallback definitions for all of them.  */
#if @HAVE_SYS_CDEFS_H@
# include <sys/cdefs.h>
#endif

#ifndef __BEGIN_DECLS
# ifdef __cplusplus
#  define __BEGIN_DECLS extern "C" {
# else
#  define __BEGIN_DECLS /* nothing */
# endif
#endif
#ifndef __END_DECLS
# ifdef __cplusplus
#  define __END_DECLS }
# else
#  define __END_DECLS /* nothing */
# endif
#endif

#ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_VERSION__
# define __GNUC_PREREQ(maj, min) \
        ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else
#  define __GNUC_PREREQ(maj, min) 0
# endif
#endif

#ifndef __THROW
# if defined __cplusplus && __GNUC_PREREQ (2,8)
#  define __THROW       throw ()
# else
#  define __THROW
# endif
#endif

#endif /* _GETOPT_CDEFS_H */


code:
/* Declarations for getopt (basic, portable features only).
   Copyright (C) 1989-2017 Free Software Foundation, Inc.
   This file is part of the GNU C Library and is also part of gnulib.
   Patches to this file should be submitted to both projects.

   The GNU C Library 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 3 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
   General Public License for more details.

   You should have received a copy of the GNU General Public
   License along with the GNU C Library; if not, see
   <http://www.gnu.org/licenses/>.  */

#ifndef _GETOPT_CORE_H
#define _GETOPT_CORE_H 1

/* This header should not be used directly; include getopt.h or
   unistd.h instead.  Unlike most bits headers, it does not have
   a protective #error, because the guard macro for getopt.h in
   gnulib is not fixed.  */

__BEGIN_DECLS

/* For communication from 'getopt' to the caller.
   When 'getopt' finds an option that takes an argument,
   the argument value is returned here.
   Also, when 'ordering' is RETURN_IN_ORDER,
   each non-option ARGV-element is returned here.  */

extern char *optarg;

/* Index in ARGV of the next element to be scanned.
   This is used for communication to and from the caller
   and for communication between successive calls to 'getopt'.

   On entry to 'getopt', zero means this is the first call; initialize.

   When 'getopt' returns -1, this is the index of the first of the
   non-option elements that the caller should itself scan.

   Otherwise, 'optind' communicates from one call to the next
   how much of ARGV has been scanned so far.  */

extern int optind;

/* Callers store zero here to inhibit the error message 'getopt' prints
   for unrecognized options.  */

extern int opterr;

/* Set to an option character which was unrecognized.  */

extern int optopt;

/* Get definitions and prototypes for functions to process the
   arguments in ARGV (ARGC of them, minus the program name) for
   options given in OPTS.

   Return the option character from OPTS just read.  Return -1 when
   there are no more options.  For unrecognized options, or options
   missing arguments, 'optopt' is set to the option letter, and '?' is
   returned.

   The OPTS string is a list of characters which are recognized option
   letters, optionally followed by colons, specifying that that letter
   takes an argument, to be placed in 'optarg'.

   If a letter in OPTS is followed by two colons, its argument is
   optional.  This behavior is specific to the GNU 'getopt'.

   The argument '--' causes premature termination of argument
   scanning, explicitly telling 'getopt' that there are no more
   options.

   If OPTS begins with '-', then non-option arguments are treated as
   arguments to the option '\1'.  This behavior is specific to the GNU
   'getopt'.  If OPTS begins with '+', or POSIXLY_CORRECT is set in
   the environment, then do not permute arguments.

   For standards compliance, the 'argv' argument has the type
   char *const *, but this is inaccurate; if argument permutation is
   enabled, the argv array (not the strings it points to) must be
   writable.  */

extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
       __THROW _GL_ARG_NONNULL ((2, 3));

__END_DECLS

#endif /* _GETOPT_CORE_H */


code:
/* Declarations for getopt (GNU extensions).
   Copyright (C) 1989-2017 Free Software Foundation, Inc.
   This file is part of the GNU C Library and is also part of gnulib.
   Patches to this file should be submitted to both projects.

   The GNU C Library 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 3 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
   General Public License for more details.

   You should have received a copy of the GNU General Public
   License along with the GNU C Library; if not, see
   <http://www.gnu.org/licenses/>.  */

#ifndef _GETOPT_EXT_H
#define _GETOPT_EXT_H 1

/* This header should not be used directly; include getopt.h instead.
   Unlike most bits headers, it does not have a protective #error,
   because the guard macro for getopt.h in gnulib is not fixed.  */

__BEGIN_DECLS

/* Describe the long-named options requested by the application.
   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
   of 'struct option' terminated by an element containing a name which is
   zero.

   The field 'has_arg' is:
   no_argument		(or 0) if the option does not take an argument,
   required_argument	(or 1) if the option requires an argument,
   optional_argument 	(or 2) if the option takes an optional argument.

   If the field 'flag' is not NULL, it points to a variable that is set
   to the value given in the field 'val' when the option is found, but
   left unchanged if the option is not found.

   To have a long-named option do something other than set an 'int' to
   a compiled-in constant, such as set a value from 'optarg', set the
   option's 'flag' field to zero and its 'val' field to a nonzero
   value (the equivalent single-letter option character, if there is
   one).  For long options that have a zero 'flag' field, 'getopt'
   returns the contents of the 'val' field.  */

struct option
{
  const char *name;
  /* has_arg can't be an enum because some compilers complain about
     type mismatches in all the code that assumes it is an int.  */
  int has_arg;
  int *flag;
  int val;
};

/* Names for the values of the 'has_arg' field of 'struct option'.  */

#define no_argument		0
#define required_argument	1
#define optional_argument	2

extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
			const char *__shortopts,
		        const struct option *__longopts, int *__longind)
       __THROW _GL_ARG_NONNULL ((2, 3));
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
			     const char *__shortopts,
		             const struct option *__longopts, int *__longind)
       __THROW _GL_ARG_NONNULL ((2, 3));

__END_DECLS

#endif /* _GETOPT_EXT_H */


code:
/* getopt (basic, portable features) gnulib wrapper header.
   Copyright (C) 1989-2017 Free Software Foundation, Inc.
   This file is part of gnulib.
   Unlike most of the getopt implementation, it is NOT shared
   with the GNU C Library.

   gnulib 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 3 of
   the License, or (at your option) any later version.

   gnulib 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 gnulib; if not, see
   <http://www.gnu.org/licenses/>.  */

#ifndef _GETOPT_PFX_CORE_H
#define _GETOPT_PFX_CORE_H 1

/* This header should not be used directly; include getopt.h or
   unistd.h instead.  It does not have a protective #error, because
   the guard macro for getopt.h in gnulib is not fixed.  */

/* Standalone applications should #define __GETOPT_PREFIX to an
   identifier that prefixes the external functions and variables
   defined in getopt-core.h and getopt-ext.h.  Systematically
   rename identifiers so that they do not collide with the system
   functions and variables.  Renaming avoids problems with some
   compilers and linkers.  */
#ifdef __GETOPT_PREFIX
# ifndef __GETOPT_ID
#  define __GETOPT_CONCAT(x, y) x ## y
#  define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
#  define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
# endif
# undef getopt
# undef optarg
# undef opterr
# undef optind
# undef optopt
# define getopt __GETOPT_ID (getopt)
# define optarg __GETOPT_ID (optarg)
# define opterr __GETOPT_ID (opterr)
# define optind __GETOPT_ID (optind)
# define optopt __GETOPT_ID (optopt)
#endif

#include <getopt-core.h>

#endif /* _GETOPT_PFX_CORE_H */


code:
/* getopt (GNU extensions) gnulib wrapper header.
   Copyright (C) 1989-2017 Free Software Foundation, Inc.
   This file is part of gnulib.
   Unlike most of the getopt implementation, it is NOT shared
   with the GNU C Library.

   gnulib 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 3 of
   the License, or (at your option) any later version.

   gnulib 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 gnulib; if not, see
   <http://www.gnu.org/licenses/>.  */

#ifndef _GETOPT_PFX_EXT_H
#define _GETOPT_PFX_EXT_H 1

/* This header should not be used directly; include getopt.h instead.
   It does not have a protective #error, because the guard macro for
   getopt.h in gnulib is not fixed.  */

/* Standalone applications should #define __GETOPT_PREFIX to an
   identifier that prefixes the external functions and variables
   defined in getopt-core.h and getopt-ext.h.  Systematically
   rename identifiers so that they do not collide with the system
   functions and variables.  Renaming avoids problems with some
   compilers and linkers.  */
#ifdef __GETOPT_PREFIX
# ifndef __GETOPT_ID
#  define __GETOPT_CONCAT(x, y) x ## y
#  define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
#  define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
# endif
# undef getopt_long
# undef getopt_long_only
# undef option
# undef _getopt_internal
# define getopt_long __GETOPT_ID (getopt_long)
# define getopt_long_only __GETOPT_ID (getopt_long_only)
# define option __GETOPT_ID (option)
# define _getopt_internal __GETOPT_ID (getopt_internal)
#endif

/* Standalone applications get correct prototypes for getopt_long and
   getopt_long_only; they declare "char **argv".  For backward
   compatibility with old applications, if __GETOPT_PREFIX is not
   defined, we supply GNU-libc-compatible, but incorrect, prototypes
   using "char *const *argv".  (GNU libc is stuck with the incorrect
   prototypes, as they are baked into older versions of LSB.)  */
#ifndef __getopt_argv_const
# if defined __GETOPT_PREFIX
#  define __getopt_argv_const /* empty */
# else
#  define __getopt_argv_const const
# endif
#endif

#include <getopt-ext.h>

#endif /* _GETOPT_PFX_EXT_H */