1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

Update Gnulib to 68b6ade.

Also add --conditional-dependencies to the flags.  See:
https://lists.gnu.org/archive/html/guile-devel/2016-07/msg00012.html
This commit is contained in:
Andy Wingo 2016-07-07 14:05:53 +02:00
parent 0d191d1394
commit d484bfbace
411 changed files with 6048 additions and 2457 deletions

View file

@ -1,6 +1,6 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
## Process this file with automake to produce Makefile.in.
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
# Copyright (C) 2002-2016 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --dir=. --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=lock --lgpl=3 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap c-strcase canonicalize-lgpl ceil clock-time close connect copysign dirfd duplocale environ extensions flock floor fpieee frexp fstat fsync full-read full-write func gendocs getaddrinfo getlogin getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isfinite isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring link listen localcharset locale log1p lstat maintainer-makefile malloc-gnu malloca mkdir mkstemp nl_langinfo nproc open pipe-posix pipe2 poll putenv readlink recv recvfrom regex rename rmdir select send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat time times trunc unistd verify vsnprintf warnings wchar
# Reproduce by: gnulib-tool --import --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=lock --lgpl=3 --conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap c-strcase canonicalize-lgpl ceil clock-time close connect copysign dirfd duplocale environ extensions flock floor fpieee frexp fstat fsync full-read full-write func gendocs getaddrinfo getlogin getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isfinite isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring link listen localcharset locale log1p lstat maintainer-makefile malloc-gnu malloca mkdir mkstemp nl_langinfo nproc open pipe-posix pipe2 poll putenv readlink recv recvfrom regex rename rmdir select send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat time times trunc unistd verify vsnprintf warnings wchar
AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects
@ -101,9 +101,11 @@ EXTRA_DIST += alignof.h
## begin gnulib module alloca
if gl_GNULIB_ENABLED_alloca
libgnu_la_LIBADD += @LTALLOCA@
libgnu_la_DEPENDENCIES += @LTALLOCA@
endif
EXTRA_DIST += alloca.c
EXTRA_libgnu_la_SOURCES += alloca.c
@ -176,6 +178,15 @@ EXTRA_DIST += arpa_inet.in.h
## end gnulib module arpa_inet
## begin gnulib module assure
if gl_GNULIB_ENABLED_assure
endif
EXTRA_DIST += assure.h
## end gnulib module assure
## begin gnulib module binary-io
libgnu_la_SOURCES += binary-io.h binary-io.c
@ -193,7 +204,9 @@ EXTRA_libgnu_la_SOURCES += bind.c
## begin gnulib module btowc
if gl_GNULIB_ENABLED_btowc
endif
EXTRA_DIST += btowc.c
EXTRA_libgnu_la_SOURCES += btowc.c
@ -391,22 +404,28 @@ EXTRA_libgnu_la_SOURCES += dirfd.c
## begin gnulib module dirname-lgpl
if gl_GNULIB_ENABLED_a691da99c1d83b83238e45f41a696f5c
libgnu_la_SOURCES += dirname-lgpl.c basename-lgpl.c stripslash.c
endif
EXTRA_DIST += dirname.h
## end gnulib module dirname-lgpl
## begin gnulib module dosname
if gl_GNULIB_ENABLED_dosname
endif
EXTRA_DIST += dosname.h
## end gnulib module dosname
## begin gnulib module dup2
if gl_GNULIB_ENABLED_dup2
endif
EXTRA_DIST += dup2.c
EXTRA_libgnu_la_SOURCES += dup2.c
@ -493,8 +512,10 @@ EXTRA_DIST += fcntl.in.h
## begin gnulib module fd-hook
if gl_GNULIB_ENABLED_43fe87a341d9b4b93c47c3ad819a5239
libgnu_la_SOURCES += fd-hook.c
endif
EXTRA_DIST += fd-hook.h
## end gnulib module fd-hook
@ -645,8 +666,10 @@ EXTRA_libgnu_la_SOURCES += getsockopt.c
## begin gnulib module gettext-h
if gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36
libgnu_la_SOURCES += gettext.h
endif
## end gnulib module gettext-h
## begin gnulib module gettimeofday
@ -699,9 +722,22 @@ EXTRA_DIST += $(top_srcdir)/build-aux/gnupload
## begin gnulib module gperf
GPERF = gperf
V_GPERF = $(V_GPERF_@AM_V@)
V_GPERF_ = $(V_GPERF_@AM_DEFAULT_V@)
V_GPERF_0 = @echo " GPERF " $@;
## end gnulib module gperf
## begin gnulib module hard-locale
if gl_GNULIB_ENABLED_30838f5439487421042f2225bed3af76
libgnu_la_SOURCES += hard-locale.c
endif
EXTRA_DIST += hard-locale.h
## end gnulib module hard-locale
## begin gnulib module havelib
@ -748,19 +784,19 @@ EXTRA_DIST += iconv.in.h
## begin gnulib module iconv_open
iconv_open-aix.h: iconv_open-aix.gperf
$(GPERF) -m 10 $(srcdir)/iconv_open-aix.gperf > $(srcdir)/iconv_open-aix.h-t
$(V_GPERF)$(GPERF) -m 10 $(srcdir)/iconv_open-aix.gperf > $(srcdir)/iconv_open-aix.h-t && \
mv $(srcdir)/iconv_open-aix.h-t $(srcdir)/iconv_open-aix.h
iconv_open-hpux.h: iconv_open-hpux.gperf
$(GPERF) -m 10 $(srcdir)/iconv_open-hpux.gperf > $(srcdir)/iconv_open-hpux.h-t
$(V_GPERF)$(GPERF) -m 10 $(srcdir)/iconv_open-hpux.gperf > $(srcdir)/iconv_open-hpux.h-t && \
mv $(srcdir)/iconv_open-hpux.h-t $(srcdir)/iconv_open-hpux.h
iconv_open-irix.h: iconv_open-irix.gperf
$(GPERF) -m 10 $(srcdir)/iconv_open-irix.gperf > $(srcdir)/iconv_open-irix.h-t
$(V_GPERF)$(GPERF) -m 10 $(srcdir)/iconv_open-irix.gperf > $(srcdir)/iconv_open-irix.h-t && \
mv $(srcdir)/iconv_open-irix.h-t $(srcdir)/iconv_open-irix.h
iconv_open-osf.h: iconv_open-osf.gperf
$(GPERF) -m 10 $(srcdir)/iconv_open-osf.gperf > $(srcdir)/iconv_open-osf.h-t
$(V_GPERF)$(GPERF) -m 10 $(srcdir)/iconv_open-osf.gperf > $(srcdir)/iconv_open-osf.h-t && \
mv $(srcdir)/iconv_open-osf.h-t $(srcdir)/iconv_open-osf.h
iconv_open-solaris.h: iconv_open-solaris.gperf
$(GPERF) -m 10 $(srcdir)/iconv_open-solaris.gperf > $(srcdir)/iconv_open-solaris.h-t
$(V_GPERF)$(GPERF) -m 10 $(srcdir)/iconv_open-solaris.gperf > $(srcdir)/iconv_open-solaris.h-t && \
mv $(srcdir)/iconv_open-solaris.h-t $(srcdir)/iconv_open-solaris.h
BUILT_SOURCES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h
MOSTLYCLEANFILES += iconv_open-aix.h-t iconv_open-hpux.h-t iconv_open-irix.h-t iconv_open-osf.h-t iconv_open-solaris.h-t
@ -791,6 +827,15 @@ EXTRA_libgnu_la_SOURCES += inet_pton.c
## end gnulib module inet_pton
## begin gnulib module intprops
if gl_GNULIB_ENABLED_intprops
endif
EXTRA_DIST += intprops.h
## end gnulib module intprops
## begin gnulib module isfinite
@ -820,7 +865,9 @@ EXTRA_libgnu_la_SOURCES += isnan.c isnand.c
## begin gnulib module isnand-nolibm
if gl_GNULIB_ENABLED_b1df7117b479d2da59d76deba468ee21
endif
EXTRA_DIST += float+.h isnan.c isnand-nolibm.h isnand.c
EXTRA_libgnu_la_SOURCES += isnan.c isnand.c
@ -838,7 +885,9 @@ EXTRA_libgnu_la_SOURCES += isnan.c isnanf.c
## begin gnulib module isnanf-nolibm
if gl_GNULIB_ENABLED_3f0e593033d1fc2c127581960f641b66
endif
EXTRA_DIST += float+.h isnan.c isnanf-nolibm.h isnanf.c
EXTRA_libgnu_la_SOURCES += isnan.c isnanf.c
@ -856,7 +905,9 @@ EXTRA_libgnu_la_SOURCES += isnan.c isnanl.c
## begin gnulib module isnanl-nolibm
if gl_GNULIB_ENABLED_dbdf22868a5367f28bf18e0013ac6f8f
endif
EXTRA_DIST += float+.h isnan.c isnanl-nolibm.h isnanl.c
EXTRA_libgnu_la_SOURCES += isnan.c isnanl.c
@ -1042,7 +1093,9 @@ EXTRA_DIST += locale.in.h
## begin gnulib module localeconv
if gl_GNULIB_ENABLED_localeconv
endif
EXTRA_DIST += localeconv.c
EXTRA_libgnu_la_SOURCES += localeconv.c
@ -1051,7 +1104,9 @@ EXTRA_libgnu_la_SOURCES += localeconv.c
## begin gnulib module log
if gl_GNULIB_ENABLED_log
endif
EXTRA_DIST += log.c
EXTRA_libgnu_la_SOURCES += log.c
@ -1394,7 +1449,9 @@ EXTRA_DIST += math.in.h
## begin gnulib module mbrtowc
if gl_GNULIB_ENABLED_mbrtowc
endif
EXTRA_DIST += mbrtowc.c
EXTRA_libgnu_la_SOURCES += mbrtowc.c
@ -1403,7 +1460,9 @@ EXTRA_libgnu_la_SOURCES += mbrtowc.c
## begin gnulib module mbsinit
if gl_GNULIB_ENABLED_mbsinit
endif
EXTRA_DIST += mbsinit.c
EXTRA_libgnu_la_SOURCES += mbsinit.c
@ -1412,7 +1471,9 @@ EXTRA_libgnu_la_SOURCES += mbsinit.c
## begin gnulib module mbtowc
if gl_GNULIB_ENABLED_mbtowc
endif
EXTRA_DIST += mbtowc-impl.h mbtowc.c
EXTRA_libgnu_la_SOURCES += mbtowc.c
@ -1421,7 +1482,9 @@ EXTRA_libgnu_la_SOURCES += mbtowc.c
## begin gnulib module memchr
if gl_GNULIB_ENABLED_memchr
endif
EXTRA_DIST += memchr.c memchr.valgrind
EXTRA_libgnu_la_SOURCES += memchr.c
@ -1446,9 +1509,33 @@ EXTRA_libgnu_la_SOURCES += mkstemp.c
## end gnulib module mkstemp
## begin gnulib module mktime
if gl_GNULIB_ENABLED_mktime
endif
EXTRA_DIST += mktime-internal.h mktime.c
EXTRA_libgnu_la_SOURCES += mktime.c
## end gnulib module mktime
## begin gnulib module mktime-internal
if gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31
endif
EXTRA_DIST += mktime-internal.h mktime.c
EXTRA_libgnu_la_SOURCES += mktime.c
## end gnulib module mktime-internal
## begin gnulib module msvc-inval
if gl_GNULIB_ENABLED_f691f076f650964c9f5598c3ee487616
endif
EXTRA_DIST += msvc-inval.c msvc-inval.h
EXTRA_libgnu_la_SOURCES += msvc-inval.c
@ -1457,7 +1544,9 @@ EXTRA_libgnu_la_SOURCES += msvc-inval.c
## begin gnulib module msvc-nothrow
if gl_GNULIB_ENABLED_676220fa4366efa9bdbfccf11a857c07
endif
EXTRA_DIST += msvc-nothrow.c msvc-nothrow.h
EXTRA_libgnu_la_SOURCES += msvc-nothrow.c
@ -1557,7 +1646,9 @@ EXTRA_libgnu_la_SOURCES += open.c
## begin gnulib module pathmax
if gl_GNULIB_ENABLED_pathmax
endif
EXTRA_DIST += pathmax.h
## end gnulib module pathmax
@ -1626,7 +1717,9 @@ EXTRA_libgnu_la_SOURCES += putenv.c
## begin gnulib module raise
if gl_GNULIB_ENABLED_raise
endif
EXTRA_DIST += raise.c
EXTRA_libgnu_la_SOURCES += raise.c
@ -1698,7 +1791,9 @@ EXTRA_libgnu_la_SOURCES += rmdir.c
## begin gnulib module round
if gl_GNULIB_ENABLED_round
endif
EXTRA_DIST += round.c
EXTRA_libgnu_la_SOURCES += round.c
@ -1725,14 +1820,18 @@ EXTRA_libgnu_la_SOURCES += safe-read.c
## begin gnulib module same-inode
if gl_GNULIB_ENABLED_9bc5f216d57e231e4834049d67d0db62
endif
EXTRA_DIST += same-inode.h
## end gnulib module same-inode
## begin gnulib module secure_getenv
if gl_GNULIB_ENABLED_secure_getenv
endif
EXTRA_DIST += secure_getenv.c
EXTRA_libgnu_la_SOURCES += secure_getenv.c
@ -1837,7 +1936,9 @@ EXTRA_DIST += signal.in.h
## begin gnulib module signbit
if gl_GNULIB_ENABLED_signbit
endif
EXTRA_DIST += float+.h signbitd.c signbitf.c signbitl.c
EXTRA_libgnu_la_SOURCES += signbitd.c signbitf.c signbitl.c
@ -1846,8 +1947,10 @@ EXTRA_libgnu_la_SOURCES += signbitd.c signbitf.c signbitl.c
## begin gnulib module size_max
if gl_GNULIB_ENABLED_size_max
libgnu_la_SOURCES += size_max.h
endif
## end gnulib module size_max
## begin gnulib module snippet/_Noreturn
@ -1958,7 +2061,9 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h
## begin gnulib module snprintf
if gl_GNULIB_ENABLED_snprintf
endif
EXTRA_DIST += snprintf.c
EXTRA_libgnu_la_SOURCES += snprintf.c
@ -1976,15 +2081,19 @@ EXTRA_libgnu_la_SOURCES += socket.c
## begin gnulib module sockets
if gl_GNULIB_ENABLED_sockets
libgnu_la_SOURCES += sockets.h sockets.c
endif
EXTRA_DIST += w32sock.h
## end gnulib module sockets
## begin gnulib module stat
if gl_GNULIB_ENABLED_stat
endif
EXTRA_DIST += stat.c
EXTRA_libgnu_la_SOURCES += stat.c
@ -2060,6 +2169,7 @@ stddef.h: stddef.in.h $(top_builddir)/config.status
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
-e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
-e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
-e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
< $(srcdir)/stddef.in.h; \
@ -2286,6 +2396,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \
-e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \
-e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \
-e 's/@''GNULIB_QSORT_R''@/$(GNULIB_QSORT_R)/g' \
-e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \
-e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \
-e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \
@ -2337,6 +2448,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
-e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
-e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
-e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \
-e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
-e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
-e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
@ -2358,7 +2470,9 @@ EXTRA_DIST += stdlib.in.h
## begin gnulib module strdup-posix
if gl_GNULIB_ENABLED_f9850631dca91859e9cddac9359921c0
endif
EXTRA_DIST += strdup.c
EXTRA_libgnu_la_SOURCES += strdup.c
@ -2367,7 +2481,9 @@ EXTRA_libgnu_la_SOURCES += strdup.c
## begin gnulib module streq
if gl_GNULIB_ENABLED_streq
endif
EXTRA_DIST += streq.h
## end gnulib module streq
@ -2786,8 +2902,10 @@ EXTRA_DIST += sys_uio.in.h
## begin gnulib module tempname
if gl_GNULIB_ENABLED_tempname
libgnu_la_SOURCES += tempname.c
endif
EXTRA_DIST += tempname.h
## end gnulib module tempname
@ -2812,10 +2930,12 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
-e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
-e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
-e 's/@''GNULIB_TIME_RZ''@/$(GNULIB_TIME_RZ)/g' \
-e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
-e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
-e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
-e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
-e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
-e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
-e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
-e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
@ -2825,6 +2945,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''UNISTD_H_DEFINES_STRUCT_TIMESPEC''@|$(UNISTD_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
@ -2839,13 +2960,35 @@ EXTRA_DIST += time.in.h
## begin gnulib module time_r
if gl_GNULIB_ENABLED_time_r
endif
EXTRA_DIST += time_r.c
EXTRA_libgnu_la_SOURCES += time_r.c
## end gnulib module time_r
## begin gnulib module time_rz
EXTRA_DIST += time-internal.h time_rz.c
EXTRA_libgnu_la_SOURCES += time_rz.c
## end gnulib module time_rz
## begin gnulib module timegm
if gl_GNULIB_ENABLED_timegm
endif
EXTRA_DIST += mktime-internal.h timegm.c
EXTRA_libgnu_la_SOURCES += timegm.c
## end gnulib module timegm
## begin gnulib module times
@ -2995,9 +3138,11 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
-e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
-e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
-e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \
-e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
-e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
-e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
-e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
-e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
-e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
-e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
@ -3088,6 +3233,17 @@ EXTRA_DIST += unitypes.in.h
## end gnulib module unitypes
## begin gnulib module unsetenv
if gl_GNULIB_ENABLED_unsetenv
endif
EXTRA_DIST += unsetenv.c
EXTRA_libgnu_la_SOURCES += unsetenv.c
## end gnulib module unsetenv
## begin gnulib module useless-if-before-free
@ -3097,7 +3253,9 @@ EXTRA_DIST += $(top_srcdir)/build-aux/useless-if-before-free
## begin gnulib module vasnprintf
if gl_GNULIB_ENABLED_vasnprintf
endif
EXTRA_DIST += asnprintf.c float+.h printf-args.c printf-args.h printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h
EXTRA_libgnu_la_SOURCES += asnprintf.c printf-args.c printf-parse.c vasnprintf.c
@ -3250,7 +3408,9 @@ EXTRA_DIST += wchar.in.h
## begin gnulib module wcrtomb
if gl_GNULIB_ENABLED_wcrtomb
endif
EXTRA_DIST += wcrtomb.c
EXTRA_libgnu_la_SOURCES += wcrtomb.c
@ -3259,6 +3419,7 @@ EXTRA_libgnu_la_SOURCES += wcrtomb.c
## begin gnulib module wctype-h
if gl_GNULIB_ENABLED_3dcce957eadc896e63ab5f137947b410
BUILT_SOURCES += wctype.h
libgnu_la_SOURCES += wctype-h.c
@ -3293,6 +3454,7 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
mv $@-t $@
MOSTLYCLEANFILES += wctype.h wctype.h-t
endif
EXTRA_DIST += wctype.in.h
## end gnulib module wctype-h
@ -3308,8 +3470,10 @@ EXTRA_libgnu_la_SOURCES += write.c
## begin gnulib module xsize
if gl_GNULIB_ENABLED_xsize
libgnu_la_SOURCES += xsize.h xsize.c
endif
## end gnulib module xsize

View file

@ -1,6 +1,6 @@
/* accept.c --- wrappers for Windows accept function
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Determine alignment of types.
Copyright (C) 2003-2004, 2006, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2003-2004, 2006, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* Memory allocation on the stack.
Copyright (C) 1995, 1999, 2001-2004, 2006-2014 Free Software Foundation,
Copyright (C) 1995, 1999, 2001-2004, 2006-2016 Free Software Foundation,
Inc.
This program is free software; you can redistribute it and/or modify it

View file

@ -1,6 +1,6 @@
/* A GNU-like <arpa/inet.h>.
Copyright (C) 2005-2006, 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2005-2006, 2008-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2006, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 1999, 2002, 2006, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

37
lib/assure.h Normal file
View file

@ -0,0 +1,37 @@
/* Run-time assert-like macros.
Copyright (C) 2014-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
#ifndef _GL_ASSURE_H
#define _GL_ASSURE_H
#include <assert.h>
/* Check E's value at runtime, and report an error and abort if not.
However, do nothng if NDEBUG is defined.
Unlike standard 'assert', this macro always compiles E even when NDEBUG
is defined, so as to catch typos and avoid some GCC warnings. */
#ifdef NDEBUG
# define assure(E) ((void) (0 && (E)))
#else
# define assure(E) assert (E)
#endif
#endif

View file

@ -1,6 +1,6 @@
/* basename.c -- return the last element in a file name
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2014 Free Software
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2016 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify

View file

@ -1,3 +1,4 @@
#include <config.h>
#define BINARY_IO_INLINE _GL_EXTERN_INLINE
#include "binary-io.h"
typedef int dummy;

View file

@ -1,5 +1,5 @@
/* Binary mode I/O.
Copyright (C) 2001, 2003, 2005, 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2001, 2003, 2005, 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -60,7 +60,7 @@ set_binary_mode (int fd, int mode)
/* SET_BINARY (fd);
changes the file descriptor fd to perform binary I/O. */
#ifdef __DJGPP__
#if defined __DJGPP__ || defined __EMX__
# include <unistd.h> /* declares isatty() */
/* Avoid putting stdin/stdout in binary mode if it is connected to
the console, because that would make it impossible for the user

View file

@ -1,6 +1,6 @@
/* bind.c --- wrappers for Windows bind function
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Convert unibyte character to wide character.
Copyright (C) 2008, 2010-2014 Free Software Foundation, Inc.
Copyright (C) 2008, 2010-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* byteswap.h - Byte swapping
Copyright (C) 2005, 2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2005, 2007, 2009-2016 Free Software Foundation, Inc.
Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
This program is free software: you can redistribute it and/or modify

View file

@ -1,395 +1,3 @@
/* Character handling in C locale.
Copyright 2000-2003, 2006, 2009-2014 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#define NO_C_CTYPE_MACROS
#define C_CTYPE_INLINE _GL_EXTERN_INLINE
#include "c-ctype.h"
/* The function isascii is not locale dependent. Its use in EBCDIC is
questionable. */
bool
c_isascii (int c)
{
return (c >= 0x00 && c <= 0x7f);
}
bool
c_isalnum (int c)
{
#if C_CTYPE_CONSECUTIVE_DIGITS \
&& C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
return ((c >= '0' && c <= '9')
|| ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'));
#else
return ((c >= '0' && c <= '9')
|| (c >= 'A' && c <= 'Z')
|| (c >= 'a' && c <= 'z'));
#endif
#else
switch (c)
{
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
return 1;
default:
return 0;
}
#endif
}
bool
c_isalpha (int c)
{
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z');
#else
return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
#endif
#else
switch (c)
{
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
return 1;
default:
return 0;
}
#endif
}
bool
c_isblank (int c)
{
return (c == ' ' || c == '\t');
}
bool
c_iscntrl (int c)
{
#if C_CTYPE_ASCII
return ((c & ~0x1f) == 0 || c == 0x7f);
#else
switch (c)
{
case ' ': case '!': case '"': case '#': case '$': case '%':
case '&': case '\'': case '(': case ')': case '*': case '+':
case ',': case '-': case '.': case '/':
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
case ':': case ';': case '<': case '=': case '>': case '?':
case '@':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case '[': case '\\': case ']': case '^': case '_': case '`':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case '{': case '|': case '}': case '~':
return 0;
default:
return 1;
}
#endif
}
bool
c_isdigit (int c)
{
#if C_CTYPE_CONSECUTIVE_DIGITS
return (c >= '0' && c <= '9');
#else
switch (c)
{
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
return 1;
default:
return 0;
}
#endif
}
bool
c_islower (int c)
{
#if C_CTYPE_CONSECUTIVE_LOWERCASE
return (c >= 'a' && c <= 'z');
#else
switch (c)
{
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
return 1;
default:
return 0;
}
#endif
}
bool
c_isgraph (int c)
{
#if C_CTYPE_ASCII
return (c >= '!' && c <= '~');
#else
switch (c)
{
case '!': case '"': case '#': case '$': case '%': case '&':
case '\'': case '(': case ')': case '*': case '+': case ',':
case '-': case '.': case '/':
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
case ':': case ';': case '<': case '=': case '>': case '?':
case '@':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case '[': case '\\': case ']': case '^': case '_': case '`':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case '{': case '|': case '}': case '~':
return 1;
default:
return 0;
}
#endif
}
bool
c_isprint (int c)
{
#if C_CTYPE_ASCII
return (c >= ' ' && c <= '~');
#else
switch (c)
{
case ' ': case '!': case '"': case '#': case '$': case '%':
case '&': case '\'': case '(': case ')': case '*': case '+':
case ',': case '-': case '.': case '/':
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
case ':': case ';': case '<': case '=': case '>': case '?':
case '@':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case '[': case '\\': case ']': case '^': case '_': case '`':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case '{': case '|': case '}': case '~':
return 1;
default:
return 0;
}
#endif
}
bool
c_ispunct (int c)
{
#if C_CTYPE_ASCII
return ((c >= '!' && c <= '~')
&& !((c >= '0' && c <= '9')
|| ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')));
#else
switch (c)
{
case '!': case '"': case '#': case '$': case '%': case '&':
case '\'': case '(': case ')': case '*': case '+': case ',':
case '-': case '.': case '/':
case ':': case ';': case '<': case '=': case '>': case '?':
case '@':
case '[': case '\\': case ']': case '^': case '_': case '`':
case '{': case '|': case '}': case '~':
return 1;
default:
return 0;
}
#endif
}
bool
c_isspace (int c)
{
return (c == ' ' || c == '\t'
|| c == '\n' || c == '\v' || c == '\f' || c == '\r');
}
bool
c_isupper (int c)
{
#if C_CTYPE_CONSECUTIVE_UPPERCASE
return (c >= 'A' && c <= 'Z');
#else
switch (c)
{
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
return 1;
default:
return 0;
}
#endif
}
bool
c_isxdigit (int c)
{
#if C_CTYPE_CONSECUTIVE_DIGITS \
&& C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
return ((c >= '0' && c <= '9')
|| ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F'));
#else
return ((c >= '0' && c <= '9')
|| (c >= 'A' && c <= 'F')
|| (c >= 'a' && c <= 'f'));
#endif
#else
switch (c)
{
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
return 1;
default:
return 0;
}
#endif
}
int
c_tolower (int c)
{
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
return (c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c);
#else
switch (c)
{
case 'A': return 'a';
case 'B': return 'b';
case 'C': return 'c';
case 'D': return 'd';
case 'E': return 'e';
case 'F': return 'f';
case 'G': return 'g';
case 'H': return 'h';
case 'I': return 'i';
case 'J': return 'j';
case 'K': return 'k';
case 'L': return 'l';
case 'M': return 'm';
case 'N': return 'n';
case 'O': return 'o';
case 'P': return 'p';
case 'Q': return 'q';
case 'R': return 'r';
case 'S': return 's';
case 'T': return 't';
case 'U': return 'u';
case 'V': return 'v';
case 'W': return 'w';
case 'X': return 'x';
case 'Y': return 'y';
case 'Z': return 'z';
default: return c;
}
#endif
}
int
c_toupper (int c)
{
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
return (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c);
#else
switch (c)
{
case 'a': return 'A';
case 'b': return 'B';
case 'c': return 'C';
case 'd': return 'D';
case 'e': return 'E';
case 'f': return 'F';
case 'g': return 'G';
case 'h': return 'H';
case 'i': return 'I';
case 'j': return 'J';
case 'k': return 'K';
case 'l': return 'L';
case 'm': return 'M';
case 'n': return 'N';
case 'o': return 'O';
case 'p': return 'P';
case 'q': return 'Q';
case 'r': return 'R';
case 's': return 'S';
case 't': return 'T';
case 'u': return 'U';
case 'v': return 'V';
case 'w': return 'W';
case 'x': return 'X';
case 'y': return 'Y';
case 'z': return 'Z';
default: return c;
}
#endif
}

View file

@ -5,7 +5,7 @@
<ctype.h> functions' behaviour depends on the current locale set via
setlocale.
Copyright (C) 2000-2003, 2006, 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2000-2003, 2006, 2008-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -25,6 +25,13 @@ along with this program; if not, see <http://www.gnu.org/licenses/>. */
#include <stdbool.h>
#ifndef _GL_INLINE_HEADER_BEGIN
#error "Please include config.h first."
#endif
_GL_INLINE_HEADER_BEGIN
#ifndef C_CTYPE_INLINE
# define C_CTYPE_INLINE _GL_INLINE
#endif
#ifdef __cplusplus
extern "C" {
@ -39,38 +46,6 @@ extern "C" {
characters. */
/* Check whether the ASCII optimizations apply. */
/* ANSI C89 (and ISO C99 5.2.1.3 too) already guarantees that
'0', '1', ..., '9' have consecutive integer values. */
#define C_CTYPE_CONSECUTIVE_DIGITS 1
#if ('A' <= 'Z') \
&& ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \
&& ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \
&& ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \
&& ('J' + 1 == 'K') && ('K' + 1 == 'L') && ('L' + 1 == 'M') \
&& ('M' + 1 == 'N') && ('N' + 1 == 'O') && ('O' + 1 == 'P') \
&& ('P' + 1 == 'Q') && ('Q' + 1 == 'R') && ('R' + 1 == 'S') \
&& ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \
&& ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \
&& ('Y' + 1 == 'Z')
#define C_CTYPE_CONSECUTIVE_UPPERCASE 1
#endif
#if ('a' <= 'z') \
&& ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \
&& ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \
&& ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \
&& ('j' + 1 == 'k') && ('k' + 1 == 'l') && ('l' + 1 == 'm') \
&& ('m' + 1 == 'n') && ('n' + 1 == 'o') && ('o' + 1 == 'p') \
&& ('p' + 1 == 'q') && ('q' + 1 == 'r') && ('r' + 1 == 's') \
&& ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \
&& ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \
&& ('y' + 1 == 'z')
#define C_CTYPE_CONSECUTIVE_LOWERCASE 1
#endif
#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
@ -96,11 +71,84 @@ extern "C" {
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)
/* The character set is ASCII or one of its variants or extensions, not EBCDIC.
Testing the value of '\n' and '\r' is not relevant. */
#define C_CTYPE_ASCII 1
# define C_CTYPE_ASCII 1
#elif ! (' ' == '\x40' && '0' == '\xf0' \
&& 'A' == '\xc1' && 'J' == '\xd1' && 'S' == '\xe2' \
&& 'a' == '\x81' && 'j' == '\x91' && 's' == '\xa2')
# error "Only ASCII and EBCDIC are supported"
#endif
#if 'A' < 0
# error "EBCDIC and char is signed -- not supported"
#endif
/* Function declarations. */
/* Cases for control characters. */
#define _C_CTYPE_CNTRL \
case '\a': case '\b': case '\f': case '\n': \
case '\r': case '\t': case '\v': \
_C_CTYPE_OTHER_CNTRL
/* ASCII control characters other than those with \-letter escapes. */
#if C_CTYPE_ASCII
# define _C_CTYPE_OTHER_CNTRL \
case '\x00': case '\x01': case '\x02': case '\x03': \
case '\x04': case '\x05': case '\x06': case '\x0e': \
case '\x0f': case '\x10': case '\x11': case '\x12': \
case '\x13': case '\x14': case '\x15': case '\x16': \
case '\x17': case '\x18': case '\x19': case '\x1a': \
case '\x1b': case '\x1c': case '\x1d': case '\x1e': \
case '\x1f': case '\x7f'
#else
/* Use EBCDIC code page 1047's assignments for ASCII control chars;
assume all EBCDIC code pages agree about these assignments. */
# define _C_CTYPE_OTHER_CNTRL \
case '\x00': case '\x01': case '\x02': case '\x03': \
case '\x07': case '\x0e': case '\x0f': case '\x10': \
case '\x11': case '\x12': case '\x13': case '\x18': \
case '\x19': case '\x1c': case '\x1d': case '\x1e': \
case '\x1f': case '\x26': case '\x27': case '\x2d': \
case '\x2e': case '\x32': case '\x37': case '\x3c': \
case '\x3d': case '\x3f'
#endif
/* Cases for lowercase hex letters, and lowercase letters, all offset by N. */
#define _C_CTYPE_LOWER_A_THRU_F_N(n) \
case 'a' + (n): case 'b' + (n): case 'c' + (n): case 'd' + (n): \
case 'e' + (n): case 'f' + (n)
#define _C_CTYPE_LOWER_N(n) \
_C_CTYPE_LOWER_A_THRU_F_N(n): \
case 'g' + (n): case 'h' + (n): case 'i' + (n): case 'j' + (n): \
case 'k' + (n): case 'l' + (n): case 'm' + (n): case 'n' + (n): \
case 'o' + (n): case 'p' + (n): case 'q' + (n): case 'r' + (n): \
case 's' + (n): case 't' + (n): case 'u' + (n): case 'v' + (n): \
case 'w' + (n): case 'x' + (n): case 'y' + (n): case 'z' + (n)
/* Cases for hex letters, digits, lower, punct, and upper. */
#define _C_CTYPE_A_THRU_F \
_C_CTYPE_LOWER_A_THRU_F_N (0): \
_C_CTYPE_LOWER_A_THRU_F_N ('A' - 'a')
#define _C_CTYPE_DIGIT \
case '0': case '1': case '2': case '3': \
case '4': case '5': case '6': case '7': \
case '8': case '9'
#define _C_CTYPE_LOWER _C_CTYPE_LOWER_N (0)
#define _C_CTYPE_PUNCT \
case '!': case '"': case '#': case '$': \
case '%': case '&': case '\'': case '(': \
case ')': case '*': case '+': case ',': \
case '-': case '.': case '/': case ':': \
case ';': case '<': case '=': case '>': \
case '?': case '@': case '[': case '\\': \
case ']': case '^': case '_': case '`': \
case '{': case '|': case '}': case '~'
#define _C_CTYPE_UPPER _C_CTYPE_LOWER_N ('A' - 'a')
/* Function definitions. */
/* Unlike the functions in <ctype.h>, which require an argument in the range
of the 'unsigned char' type, the functions here operate on values that are
@ -117,179 +165,202 @@ extern "C" {
if (c_isalpha (*s)) ...
*/
extern bool c_isascii (int c) _GL_ATTRIBUTE_CONST; /* not locale dependent */
C_CTYPE_INLINE bool
c_isalnum (int c)
{
switch (c)
{
_C_CTYPE_DIGIT:
_C_CTYPE_LOWER:
_C_CTYPE_UPPER:
return true;
default:
return false;
}
}
extern bool c_isalnum (int c) _GL_ATTRIBUTE_CONST;
extern bool c_isalpha (int c) _GL_ATTRIBUTE_CONST;
extern bool c_isblank (int c) _GL_ATTRIBUTE_CONST;
extern bool c_iscntrl (int c) _GL_ATTRIBUTE_CONST;
extern bool c_isdigit (int c) _GL_ATTRIBUTE_CONST;
extern bool c_islower (int c) _GL_ATTRIBUTE_CONST;
extern bool c_isgraph (int c) _GL_ATTRIBUTE_CONST;
extern bool c_isprint (int c) _GL_ATTRIBUTE_CONST;
extern bool c_ispunct (int c) _GL_ATTRIBUTE_CONST;
extern bool c_isspace (int c) _GL_ATTRIBUTE_CONST;
extern bool c_isupper (int c) _GL_ATTRIBUTE_CONST;
extern bool c_isxdigit (int c) _GL_ATTRIBUTE_CONST;
C_CTYPE_INLINE bool
c_isalpha (int c)
{
switch (c)
{
_C_CTYPE_LOWER:
_C_CTYPE_UPPER:
return true;
default:
return false;
}
}
extern int c_tolower (int c) _GL_ATTRIBUTE_CONST;
extern int c_toupper (int c) _GL_ATTRIBUTE_CONST;
/* The function isascii is not locale dependent.
Its use in EBCDIC is questionable. */
C_CTYPE_INLINE bool
c_isascii (int c)
{
switch (c)
{
case ' ':
_C_CTYPE_CNTRL:
_C_CTYPE_DIGIT:
_C_CTYPE_LOWER:
_C_CTYPE_PUNCT:
_C_CTYPE_UPPER:
return true;
default:
return false;
}
}
C_CTYPE_INLINE bool
c_isblank (int c)
{
return c == ' ' || c == '\t';
}
#if (defined __GNUC__ && !defined __STRICT_ANSI__ && defined __OPTIMIZE__ \
&& !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS)
C_CTYPE_INLINE bool
c_iscntrl (int c)
{
switch (c)
{
_C_CTYPE_CNTRL:
return true;
default:
return false;
}
}
/* ASCII optimizations. */
C_CTYPE_INLINE bool
c_isdigit (int c)
{
switch (c)
{
_C_CTYPE_DIGIT:
return true;
default:
return false;
}
}
#undef c_isascii
#define c_isascii(c) \
({ int __c = (c); \
(__c >= 0x00 && __c <= 0x7f); \
})
C_CTYPE_INLINE bool
c_isgraph (int c)
{
switch (c)
{
_C_CTYPE_DIGIT:
_C_CTYPE_LOWER:
_C_CTYPE_PUNCT:
_C_CTYPE_UPPER:
return true;
default:
return false;
}
}
#if C_CTYPE_CONSECUTIVE_DIGITS \
&& C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
#undef c_isalnum
#define c_isalnum(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
|| ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \
})
#else
#undef c_isalnum
#define c_isalnum(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
|| (__c >= 'A' && __c <= 'Z') \
|| (__c >= 'a' && __c <= 'z')); \
})
#endif
#endif
C_CTYPE_INLINE bool
c_islower (int c)
{
switch (c)
{
_C_CTYPE_LOWER:
return true;
default:
return false;
}
}
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
#undef c_isalpha
#define c_isalpha(c) \
({ int __c = (c); \
((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \
})
#else
#undef c_isalpha
#define c_isalpha(c) \
({ int __c = (c); \
((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \
})
#endif
#endif
C_CTYPE_INLINE bool
c_isprint (int c)
{
switch (c)
{
case ' ':
_C_CTYPE_DIGIT:
_C_CTYPE_LOWER:
_C_CTYPE_PUNCT:
_C_CTYPE_UPPER:
return true;
default:
return false;
}
}
#undef c_isblank
#define c_isblank(c) \
({ int __c = (c); \
(__c == ' ' || __c == '\t'); \
})
C_CTYPE_INLINE bool
c_ispunct (int c)
{
switch (c)
{
_C_CTYPE_PUNCT:
return true;
default:
return false;
}
}
#if C_CTYPE_ASCII
#undef c_iscntrl
#define c_iscntrl(c) \
({ int __c = (c); \
((__c & ~0x1f) == 0 || __c == 0x7f); \
})
#endif
C_CTYPE_INLINE bool
c_isspace (int c)
{
switch (c)
{
case ' ': case '\t': case '\n': case '\v': case '\f': case '\r':
return true;
default:
return false;
}
}
#if C_CTYPE_CONSECUTIVE_DIGITS
#undef c_isdigit
#define c_isdigit(c) \
({ int __c = (c); \
(__c >= '0' && __c <= '9'); \
})
#endif
C_CTYPE_INLINE bool
c_isupper (int c)
{
switch (c)
{
_C_CTYPE_UPPER:
return true;
default:
return false;
}
}
#if C_CTYPE_CONSECUTIVE_LOWERCASE
#undef c_islower
#define c_islower(c) \
({ int __c = (c); \
(__c >= 'a' && __c <= 'z'); \
})
#endif
C_CTYPE_INLINE bool
c_isxdigit (int c)
{
switch (c)
{
_C_CTYPE_DIGIT:
_C_CTYPE_A_THRU_F:
return true;
default:
return false;
}
}
#if C_CTYPE_ASCII
#undef c_isgraph
#define c_isgraph(c) \
({ int __c = (c); \
(__c >= '!' && __c <= '~'); \
})
#endif
#if C_CTYPE_ASCII
#undef c_isprint
#define c_isprint(c) \
({ int __c = (c); \
(__c >= ' ' && __c <= '~'); \
})
#endif
#if C_CTYPE_ASCII
#undef c_ispunct
#define c_ispunct(c) \
({ int _c = (c); \
(c_isgraph (_c) && ! c_isalnum (_c)); \
})
#endif
#undef c_isspace
#define c_isspace(c) \
({ int __c = (c); \
(__c == ' ' || __c == '\t' \
|| __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \
})
#if C_CTYPE_CONSECUTIVE_UPPERCASE
#undef c_isupper
#define c_isupper(c) \
({ int __c = (c); \
(__c >= 'A' && __c <= 'Z'); \
})
#endif
#if C_CTYPE_CONSECUTIVE_DIGITS \
&& C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
#undef c_isxdigit
#define c_isxdigit(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
|| ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \
})
#else
#undef c_isxdigit
#define c_isxdigit(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
|| (__c >= 'A' && __c <= 'F') \
|| (__c >= 'a' && __c <= 'f')); \
})
#endif
#endif
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#undef c_tolower
#define c_tolower(c) \
({ int __c = (c); \
(__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \
})
#undef c_toupper
#define c_toupper(c) \
({ int __c = (c); \
(__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \
})
#endif
#endif /* optimizing for speed */
C_CTYPE_INLINE int
c_tolower (int c)
{
switch (c)
{
_C_CTYPE_UPPER:
return c - 'A' + 'a';
default:
return c;
}
}
C_CTYPE_INLINE int
c_toupper (int c)
{
switch (c)
{
_C_CTYPE_LOWER:
return c - 'a' + 'A';
default:
return c;
}
}
#ifdef __cplusplus
}
#endif
_GL_INLINE_HEADER_END
#endif /* C_CTYPE_H */

View file

@ -1,5 +1,5 @@
/* Case-insensitive string comparison functions in C locale.
Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2014 Free Software
Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2016 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* c-strcasecmp.c -- case insensitive string comparator in C locale
Copyright (C) 1998-1999, 2005-2006, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 1998-1999, 2005-2006, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Optimized case-insensitive string comparison in C locale.
Copyright (C) 2001-2002, 2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2001-2002, 2007, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
@ -33,9 +33,6 @@
# if C_CTYPE_ASCII
# define CASEEQ(other,upper) \
(c_isupper (upper) ? ((other) & ~0x20) == (upper) : (other) == (upper))
# elif C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
# define CASEEQ(other,upper) \
(c_isupper (upper) ? (other) == (upper) || (other) == (upper) - 'A' + 'a' : (other) == (upper))
# else
# define CASEEQ(other,upper) \
(c_toupper (other) == (upper))

View file

@ -1,5 +1,5 @@
/* c-strncasecmp.c -- case insensitive string comparator in C locale
Copyright (C) 1998-1999, 2005-2006, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 1998-1999, 2005-2006, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Return the canonical absolute name of a given file.
Copyright (C) 1996-2014 Free Software Foundation, Inc.
Copyright (C) 1996-2016 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

View file

@ -1,5 +1,5 @@
/* Round towards positive infinity.
Copyright (C) 2007, 2010-2014 Free Software Foundation, Inc.
Copyright (C) 2007, 2010-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* close replacement.
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,7 +1,7 @@
#! /bin/sh
# Output a system dependent table of character encoding aliases.
#
# Copyright (C) 2000-2004, 2006-2014 Free Software Foundation, Inc.
# Copyright (C) 2000-2004, 2006-2016 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
@ -348,12 +348,10 @@ case "$os" in
#echo "sun_eu_greek ?" # what is this?
echo "UTF-8 UTF-8"
;;
freebsd* | os2*)
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.
# Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
# reuse FreeBSD's locale data for OS/2.
echo "C ASCII"
echo "US-ASCII ASCII"
for l in la_LN lt_LN; do

View file

@ -1,6 +1,6 @@
/* connect.c --- wrappers for Windows connect function
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Copy sign into another 'double' number.
Copyright (C) 2011-2014 Free Software Foundation, Inc.
Copyright (C) 2011-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* A GNU-like <dirent.h>.
Copyright (C) 2006-2014 Free Software Foundation, Inc.
Copyright (C) 2006-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -77,6 +77,7 @@ typedef struct gl_directory DIR;
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef opendir
# define opendir rpl_opendir
# define GNULIB_defined_opendir 1
# endif
_GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
@ -128,6 +129,7 @@ _GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef closedir
# define closedir rpl_closedir
# define GNULIB_defined_closedir 1
# endif
_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
@ -156,6 +158,13 @@ _GL_WARN_ON_USE (closedir, "closedir is not portable - "
# endif
_GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (dirfd, int, (DIR *));
# ifdef __KLIBC__
/* Gnulib internal hooks needed to maintain the dirfd metadata. */
_GL_EXTERN_C int _gl_register_dirp_fd (int fd, DIR *dirp)
_GL_ARG_NONNULL ((2));
_GL_EXTERN_C void _gl_unregister_dirp_fd (int fd);
# endif
# else
# if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
/* dirfd is defined as a macro and not as a function.

View file

@ -1,6 +1,6 @@
/* dirfd.c -- return the file descriptor associated with an open DIR*
Copyright (C) 2001, 2006, 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2001, 2006, 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -22,11 +22,77 @@
#include <dirent.h>
#include <errno.h>
#ifdef __KLIBC__
# include <stdlib.h>
# include <io.h>
static struct dirp_fd_list
{
DIR *dirp;
int fd;
struct dirp_fd_list *next;
} *dirp_fd_start = NULL;
/* Register fd associated with dirp to dirp_fd_list. */
int
_gl_register_dirp_fd (int fd, DIR *dirp)
{
struct dirp_fd_list *new_dirp_fd = malloc (sizeof *new_dirp_fd);
if (!new_dirp_fd)
return -1;
new_dirp_fd->dirp = dirp;
new_dirp_fd->fd = fd;
new_dirp_fd->next = dirp_fd_start;
dirp_fd_start = new_dirp_fd;
return 0;
}
/* Unregister fd from dirp_fd_list with closing it */
void
_gl_unregister_dirp_fd (int fd)
{
struct dirp_fd_list *dirp_fd;
struct dirp_fd_list *dirp_fd_prev;
for (dirp_fd_prev = NULL, dirp_fd = dirp_fd_start; dirp_fd;
dirp_fd_prev = dirp_fd, dirp_fd = dirp_fd->next)
{
if (dirp_fd->fd == fd)
{
if (dirp_fd_prev)
dirp_fd_prev->next = dirp_fd->next;
else /* dirp_fd == dirp_fd_start */
dirp_fd_start = dirp_fd_start->next;
close (fd);
free (dirp_fd);
break;
}
}
}
#endif
int
dirfd (DIR *dir_p)
{
int fd = DIR_TO_FD (dir_p);
if (fd == -1)
#ifndef __KLIBC__
errno = ENOTSUP;
#else
{
struct dirp_fd_list *dirp_fd;
for (dirp_fd = dirp_fd_start; dirp_fd; dirp_fd = dirp_fd->next)
if (dirp_fd->dirp == dir_p)
return dirp_fd->fd;
errno = EINVAL;
}
#endif
return fd;
}

View file

@ -1,6 +1,6 @@
/* dirname.c -- return all but the last element in a file name
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2014 Free Software
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2016 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* Take file names apart into directory and base names.
Copyright (C) 1998, 2001, 2003-2006, 2009-2014 Free Software Foundation,
Copyright (C) 1998, 2001, 2003-2006, 2009-2016 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
@ -31,6 +31,10 @@
# 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);
@ -43,4 +47,8 @@ char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
bool strip_trailing_slashes (char *file);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* not DIRNAME_H_ */

View file

@ -1,6 +1,6 @@
/* File names on MS-DOS/Windows systems.
Copyright (C) 2000-2001, 2004-2006, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2000-2001, 2004-2006, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* Duplicate an open file descriptor to a specified file descriptor.
Copyright (C) 1999, 2004-2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 1999, 2004-2007, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -85,6 +85,57 @@ ms_windows_dup2 (int fd, int desired_fd)
# define dup2 ms_windows_dup2
# elif defined __KLIBC__
# include <InnoTekLIBC/backend.h>
static int
klibc_dup2dirfd (int fd, int desired_fd)
{
int tempfd;
int dupfd;
tempfd = open ("NUL", O_RDONLY);
if (tempfd == -1)
return -1;
if (tempfd == desired_fd)
{
close (tempfd);
char path[_MAX_PATH];
if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
return -1;
return open(path, O_RDONLY);
}
dupfd = klibc_dup2dirfd (fd, desired_fd);
close (tempfd);
return dupfd;
}
static int
klibc_dup2 (int fd, int desired_fd)
{
int dupfd;
struct stat sbuf;
dupfd = dup2 (fd, desired_fd);
if (dupfd == -1 && errno == ENOTSUP \
&& !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
{
close (desired_fd);
return klibc_dup2dirfd (fd, desired_fd);
}
return dupfd;
}
# define dup2 klibc_dup2
# endif
int

View file

@ -1,5 +1,5 @@
/* Duplicate a locale object.
Copyright (C) 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* A POSIX-like <errno.h>.
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* Like <fcntl.h>, but with non-working flags defined to 0.
Copyright (C) 2006-2014 Free Software Foundation, Inc.
Copyright (C) 2006-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -34,7 +34,7 @@
extern "C" { ... } block, which leads to errors in C++ mode with the
overridden <sys/stat.h> from gnulib. These errors are known to be gone
with g++ version >= 4.3. */
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
# include <sys/stat.h>
#endif
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
@ -53,7 +53,7 @@
extern "C" { ... } block, which leads to errors in C++ mode with the
overridden <sys/stat.h> from gnulib. These errors are known to be gone
with g++ version >= 4.3. */
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
# include <sys/stat.h>
#endif
/* The include_next requires a split double-inclusion guard. */
@ -186,6 +186,22 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
/* Fix up the O_* macros. */
/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
to values outside 'int' range, so omit these misdefinitions.
But avoid namespace pollution on non-AIX systems. */
#ifdef _AIX
# include <limits.h>
# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
# undef O_CLOEXEC
# endif
# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
# undef O_NOFOLLOW
# endif
# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
# undef O_TTY_INIT
# endif
#endif
#if !defined O_DIRECT && defined O_DIRECTIO
/* Tru64 spells it 'O_DIRECTIO'. */
# define O_DIRECT O_DIRECTIO

View file

@ -1,5 +1,5 @@
/* Hook for making making file descriptor functions close(), ioctl() extensible.
Copyright (C) 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2009-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it

View file

@ -1,5 +1,5 @@
/* Hook for making making file descriptor functions close(), ioctl() extensible.
Copyright (C) 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published

View file

@ -1,5 +1,5 @@
/* Supplemental information about the floating-point formats.
Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This program is free software; you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Auxiliary definitions for <float.h>.
Copyright (C) 2011-2014 Free Software Foundation, Inc.
Copyright (C) 2011-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This program is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* A correct <float.h>.
Copyright (C) 2007-2014 Free Software Foundation, Inc.
Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -6,7 +6,7 @@
Written by Richard W.M. Jones <rjones.at.redhat.com>
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public

View file

@ -1,5 +1,5 @@
/* Round towards negative infinity.
Copyright (C) 2007, 2010-2014 Free Software Foundation, Inc.
Copyright (C) 2007, 2010-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Split a double into fraction and mantissa.
Copyright (C) 2007-2014 Free Software Foundation, Inc.
Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* fstat() replacement.
Copyright (C) 2011-2014 Free Software Foundation, Inc.
Copyright (C) 2011-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -7,7 +7,7 @@
Written by Richard W.M. Jones <rjones.at.redhat.com>
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public

View file

@ -1,5 +1,5 @@
/* An interface to read that retries after partial reads and interrupts.
Copyright (C) 2002-2003, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2002-2003, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* An interface to read() that reads all it is asked to read.
Copyright (C) 2002, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2002, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -13,7 +13,6 @@
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, read to the Free Software Foundation,
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stddef.h>

View file

@ -1,6 +1,6 @@
/* An interface to read and write that retries (if necessary) until complete.
Copyright (C) 1993-1994, 1997-2006, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 1993-1994, 1997-2006, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* An interface to write() that writes all it is asked to write.
Copyright (C) 2002-2003, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2002-2003, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2014 Free Software
/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2016 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.

View file

@ -1,5 +1,5 @@
/* Get address information (partial implementation).
Copyright (C) 1997, 2001-2002, 2004-2014 Free Software Foundation, Inc.
Copyright (C) 1997, 2001-2002, 2004-2016 Free Software Foundation, Inc.
Contributed by Simon Josefsson <simon@josefsson.org>.
This program is free software; you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* Provide a working getlogin for systems which lack it.
Copyright (C) 2010-2014 Free Software Foundation, Inc.
Copyright (C) 2010-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* getpeername.c --- wrappers for Windows getpeername function
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* getsockname.c --- wrappers for Windows getsockname function
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* getsockopt.c --- wrappers for Windows getsockopt function
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2014 Free Software
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2016 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@ -225,15 +225,17 @@ dcpgettext_expr (const char *domain,
if (msg_ctxt_id != NULL)
#endif
{
int found_translation;
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcgettext (domain, msg_ctxt_id, category);
found_translation = (translation != msg_ctxt_id);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
if (translation != msg_ctxt_id)
if (found_translation)
return translation;
}
return msgid;
@ -271,15 +273,17 @@ dcnpgettext_expr (const char *domain,
if (msg_ctxt_id != NULL)
#endif
{
int found_translation;
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
if (!(translation == msg_ctxt_id || translation == msgid_plural))
if (found_translation)
return translation;
}
return (n == 1 ? msgid : msgid_plural);

View file

@ -1,6 +1,6 @@
/* Provide gettimeofday for systems that don't have it or for which it's broken.
Copyright (C) 2001-2003, 2005-2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2001-2003, 2005-2007, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

72
lib/hard-locale.c Normal file
View file

@ -0,0 +1,72 @@
/* hard-locale.c -- Determine whether a locale is hard.
Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2016 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "hard-locale.h"
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#ifdef __GLIBC__
# define GLIBC_VERSION __GLIBC__
#elif defined __UCLIBC__
# define GLIBC_VERSION 2
#else
# define GLIBC_VERSION 0
#endif
/* Return true if the current CATEGORY locale is hard, i.e. if you
can't get away with assuming traditional C or POSIX behavior. */
bool
hard_locale (int category)
{
bool hard = true;
char const *p = setlocale (category, NULL);
if (p)
{
if (2 <= GLIBC_VERSION)
{
if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
hard = false;
}
else
{
char *locale = strdup (p);
if (locale)
{
/* Temporarily set the locale to the "C" and "POSIX" locales
to find their names, so that we can determine whether one
or the other is the caller's locale. */
if (((p = setlocale (category, "C"))
&& strcmp (p, locale) == 0)
|| ((p = setlocale (category, "POSIX"))
&& strcmp (p, locale) == 0))
hard = false;
/* Restore the caller's locale. */
setlocale (category, locale);
free (locale);
}
}
}
return hard;
}

25
lib/hard-locale.h Normal file
View file

@ -0,0 +1,25 @@
/* Determine whether a locale is hard.
Copyright (C) 1999, 2003-2004, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef HARD_LOCALE_H_
# define HARD_LOCALE_H_ 1
# include <stdbool.h>
bool hard_locale (int);
#endif /* HARD_LOCALE_H_ */

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 1999-2001, 2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 1999-2001, 2007, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* A GNU-like <iconv.h>.
Copyright (C) 2007-2014 Free Software Foundation, Inc.
Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Character set conversion handler type.
Copyright (C) 2001-2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2001-2007, 2009-2016 Free Software Foundation, Inc.
Written by Bruno Haible.
This program is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
Copyright (C) 2005-2006, 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2005-2006, 2008-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -40,7 +40,7 @@
/* Use this to suppress gcc's "...may be used before initialized" warnings.
Beware: The Code argument must not contain commas. */
#ifndef IF_LINT
# ifdef lint
# if defined GCC_LINT || defined lint
# define IF_LINT(Code) Code
# else
# define IF_LINT(Code) /* empty */

View file

@ -1,6 +1,6 @@
/* inet_pton.c -- convert IPv4 and IPv6 addresses from text to binary form
Copyright (C) 2006, 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2006, 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

445
lib/intprops.h Normal file
View file

@ -0,0 +1,445 @@
/* intprops.h -- properties of integer types
Copyright (C) 2001-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
#ifndef _GL_INTPROPS_H
#define _GL_INTPROPS_H
#include <limits.h>
#include <verify.h>
/* Return a value with the common real type of E and V and the value of V. */
#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */
#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
/* The extra casts in the following macros work around compiler bugs,
e.g., in Cray C 5.0.3.0. */
/* True if the arithmetic type T is an integer type. bool counts as
an integer. */
#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
/* True if the real type T is signed. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* Return 1 if the real expression E, after promotion, has a
signed or floating type. */
#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
/* Minimum and maximum values for integer types and expressions. */
/* The maximum and minimum values for the integer type T. */
#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
#define TYPE_MAXIMUM(t) \
((t) (! TYPE_SIGNED (t) \
? (t) -1 \
: ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
/* The maximum and minimum values for the type of the expression E,
after integer promotion. E should not have side effects. */
#define _GL_INT_MINIMUM(e) \
(EXPR_SIGNED (e) \
? ~ _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_CONVERT (e, 0))
#define _GL_INT_MAXIMUM(e) \
(EXPR_SIGNED (e) \
? _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_NEGATE_CONVERT (e, 1))
#define _GL_SIGNED_INT_MAXIMUM(e) \
(((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1)
/* This include file assumes that signed types are two's complement without
padding bits; the above macros have undefined behavior otherwise.
If this is a problem for you, please let us know how to fix it for your host.
As a sanity check, test the assumption for some signed types that
<limits.h> bounds. */
verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
verify (TYPE_MINIMUM (short int) == SHRT_MIN);
verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
verify (TYPE_MINIMUM (int) == INT_MIN);
verify (TYPE_MAXIMUM (int) == INT_MAX);
verify (TYPE_MINIMUM (long int) == LONG_MIN);
verify (TYPE_MAXIMUM (long int) == LONG_MAX);
#ifdef LLONG_MAX
verify (TYPE_MINIMUM (long long int) == LLONG_MIN);
verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
#endif
/* Does the __typeof__ keyword work? This could be done by
'configure', but for now it's easier to do it by hand. */
#if (2 <= __GNUC__ || defined __IBM__TYPEOF__ \
|| (0x5110 <= __SUNPRO_C && !__STDC__))
# define _GL_HAVE___TYPEOF__ 1
#else
# define _GL_HAVE___TYPEOF__ 0
#endif
/* Return 1 if the integer type or expression T might be signed. Return 0
if it is definitely unsigned. This macro does not evaluate its argument,
and expands to an integer constant expression. */
#if _GL_HAVE___TYPEOF__
# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
#else
# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
#endif
/* Bound on length of the string representing an unsigned integer
value representable in B bits. log10 (2.0) < 146/485. The
smallest value of B where this bound is not tight is 2621. */
#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
/* Bound on length of the string representing an integer type or expression T.
Subtract 1 for the sign bit if T is signed, and then add 1 more for
a minus sign if needed.
Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is
signed, this macro may overestimate the true bound by one byte when
applied to unsigned types of size 2, 4, 16, ... bytes. */
#define INT_STRLEN_BOUND(t) \
(INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT \
- _GL_SIGNED_TYPE_OR_EXPR (t)) \
+ _GL_SIGNED_TYPE_OR_EXPR (t))
/* Bound on buffer size needed to represent an integer type or expression T,
including the terminating null. */
#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
/* Range overflow checks.
The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
operators might not yield numerically correct answers due to
arithmetic overflow. They do not rely on undefined or
implementation-defined behavior. Their implementations are simple
and straightforward, but they are a bit harder to use than the
INT_<op>_OVERFLOW macros described below.
Example usage:
long int i = ...;
long int j = ...;
if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX))
printf ("multiply would overflow");
else
printf ("product is %ld", i * j);
Restrictions on *_RANGE_OVERFLOW macros:
These macros do not check for all possible numerical problems or
undefined or unspecified behavior: they do not check for division
by zero, for bad shift counts, or for shifting negative numbers.
These macros may evaluate their arguments zero or multiple times,
so the arguments should not have side effects. The arithmetic
arguments (including the MIN and MAX arguments) must be of the same
integer type after the usual arithmetic conversions, and the type
must have minimum value MIN and maximum MAX. Unsigned types should
use a zero MIN of the proper type.
These macros are tuned for constant MIN and MAX. For commutative
operations such as A + B, they are also tuned for constant B. */
/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. */
#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \
((b) < 0 \
? (a) < (min) - (b) \
: (max) - (b) < (a))
/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. */
#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \
((b) < 0 \
? (max) + (b) < (a) \
: (a) < (min) + (b))
/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
See above for restrictions. */
#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
((min) < 0 \
? (a) < - (max) \
: 0 < (a))
/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Avoid && and || as they tickle
bugs in Sun C 5.11 2010/08/13 and other compilers; see
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */
#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
((b) < 0 \
? ((a) < 0 \
? (a) < (max) / (b) \
: (b) == -1 \
? 0 \
: (min) / (b) < (a)) \
: (b) == 0 \
? 0 \
: ((a) < 0 \
? (a) < (min) / (b) \
: (max) / (b) < (a)))
/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Do not check for division by zero. */
#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \
((min) < 0 && (b) == -1 && (a) < - (max))
/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Do not check for division by zero.
Mathematically, % should never overflow, but on x86-like hosts
INT_MIN % -1 traps, and the C standard permits this, so treat this
as an overflow too. */
#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \
INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max)
/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Here, MIN and MAX are for A only, and B need
not be of the same type as the other arguments. The C standard says that
behavior is undefined for shifts unless 0 <= B < wordwidth, and that when
A is negative then A << B has undefined behavior and A >> B has
implementation-defined behavior, but do not check these other
restrictions. */
#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \
((a) < 0 \
? (a) < (min) >> (b) \
: (max) >> (b) < (a))
/* True if __builtin_add_overflow (A, B, P) works when P is null. */
#define _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL (7 <= __GNUC__)
/* The _GL*_OVERFLOW macros have the same restrictions as the
*_RANGE_OVERFLOW macros, except that they do not assume that operands
(e.g., A and B) have the same type as MIN and MAX. Instead, they assume
that the result (e.g., A + B) has that type. */
#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL
# define _GL_ADD_OVERFLOW(a, b, min, max)
__builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0)
# define _GL_SUBTRACT_OVERFLOW(a, b, min, max)
__builtin_sub_overflow (a, b, (__typeof__ ((a) - (b)) *) 0)
# define _GL_MULTIPLY_OVERFLOW(a, b, min, max)
__builtin_mul_overflow (a, b, (__typeof__ ((a) * (b)) *) 0)
#else
# define _GL_ADD_OVERFLOW(a, b, min, max) \
((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
: (a) < 0 ? (b) <= (a) + (b) \
: (b) < 0 ? (a) <= (a) + (b) \
: (a) + (b) < (b))
# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
: (a) < 0 ? 1 \
: (b) < 0 ? (a) - (b) <= (a) \
: (a) < (b))
# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
(((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
|| INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
#endif
#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
: (a) < 0 ? (b) <= (a) + (b) - 1 \
: (b) < 0 && (a) + (b) <= (a))
#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \
((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
: (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \
: (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max))
/* Return a nonzero value if A is a mathematical multiple of B, where
A is unsigned, B is negative, and MAX is the maximum value of A's
type. A's type must be the same as (A % B)'s type. Normally (A %
-B == 0) suffices, but things get tricky if -B would overflow. */
#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \
(((b) < -_GL_SIGNED_INT_MAXIMUM (b) \
? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \
? (a) \
: (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \
: (a) % - (b)) \
== 0)
/* Check for integer overflow, and report low order bits of answer.
The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
might not yield numerically correct answers due to arithmetic overflow.
The INT_<op>_WRAPV macros also store the low-order bits of the answer.
These macros work correctly on all known practical hosts, and do not rely
on undefined behavior due to signed arithmetic overflow.
Example usage, assuming A and B are long int:
if (INT_MULTIPLY_OVERFLOW (a, b))
printf ("result would overflow\n");
else
printf ("result is %ld (no overflow)\n", a * b);
Example usage with WRAPV flavor:
long int result;
bool overflow = INT_MULTIPLY_WRAPV (a, b, &result);
printf ("result is %ld (%s)\n", result,
overflow ? "after overflow" : "no overflow");
Restrictions on these macros:
These macros do not check for all possible numerical problems or
undefined or unspecified behavior: they do not check for division
by zero, for bad shift counts, or for shifting negative numbers.
These macros may evaluate their arguments zero or multiple times, so the
arguments should not have side effects.
The WRAPV macros are not constant expressions. They support only
+, binary -, and *. The result type must be signed.
These macros are tuned for their last argument being a constant.
Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
A % B, and A << B would overflow, respectively. */
#define INT_ADD_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
#define INT_SUBTRACT_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL
# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a)
#else
# define INT_NEGATE_OVERFLOW(a) \
INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
#endif
#define INT_MULTIPLY_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
#define INT_DIVIDE_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW)
#define INT_REMAINDER_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW)
#define INT_LEFT_SHIFT_OVERFLOW(a, b) \
INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \
_GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
/* Return 1 if the expression A <op> B would overflow,
where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test,
assuming MIN and MAX are the minimum and maximum for the result type.
Arguments should be free of side effects. */
#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
op_result_overflow (a, b, \
_GL_INT_MINIMUM (0 * (b) + (a)), \
_GL_INT_MAXIMUM (0 * (b) + (a)))
/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
Return 1 if the result overflows. See above for restrictions. */
#define INT_ADD_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW)
#define INT_SUBTRACT_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, -, __builtin_sub_overflow, INT_SUBTRACT_OVERFLOW)
#define INT_MULTIPLY_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW)
#ifndef __has_builtin
# define __has_builtin(x) 0
#endif
/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
https://llvm.org/bugs/show_bug.cgi?id=25390
For now, assume all versions of GCC-like compilers generate bogus
warnings for _Generic. This matters only for older compilers that
lack __builtin_add_overflow. */
#if __GNUC__
# define _GL__GENERIC_BOGUS 1
#else
# define _GL__GENERIC_BOGUS 0
#endif
/* Store the low-order bits of A <op> B into *R, where OP specifies
the operation. BUILTIN is the builtin operation, and OVERFLOW the
overflow predicate. Return 1 if the result overflows. See above
for restrictions. */
#if 5 <= __GNUC__ || __has_builtin (__builtin_add_overflow)
# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r)
#elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
(_Generic \
(*(r), \
signed char: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
signed char, SCHAR_MIN, SCHAR_MAX), \
short int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
short int, SHRT_MIN, SHRT_MAX), \
int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
int, INT_MIN, INT_MAX), \
long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX), \
long long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
long long int, LLONG_MIN, LLONG_MAX)))
#else
# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
(sizeof *(r) == sizeof (signed char) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
signed char, SCHAR_MIN, SCHAR_MAX) \
: sizeof *(r) == sizeof (short int) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
short int, SHRT_MIN, SHRT_MAX) \
: sizeof *(r) == sizeof (int) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
int, INT_MIN, INT_MAX) \
: _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
# ifdef LLONG_MAX
# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
(sizeof *(r) == sizeof (long int) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
long long int, LLONG_MIN, LLONG_MAX))
# else
# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX))
# endif
#endif
/* Store the low-order bits of A <op> B into *R, where the operation
is given by OP. Use the unsigned type UT for calculation to avoid
overflow problems. *R's type is T, with extremal values TMIN and
TMAX. T must be a signed integer type. Return 1 if the result
overflows. */
#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
(sizeof ((a) op (b)) < sizeof (t) \
? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
: _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax))
#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \
((overflow (a, b) \
|| (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
|| (tmax) < ((a) op (b))) \
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 1) \
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 0))
/* Return A <op> B, where the operation is given by OP. Use the
unsigned type UT for calculation to avoid overflow problems.
Convert the result to type T without overflow by subtracting TMIN
from large values before converting, and adding it afterwards.
Compilers can optimize all the operations except OP. */
#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t, tmin, tmax) \
(((ut) (a) op (ut) (b)) <= (tmax) \
? (t) ((ut) (a) op (ut) (b)) \
: ((t) (((ut) (a) op (ut) (b)) - (tmin)) + (tmin)))
#endif /* _GL_INTPROPS_H */

View file

@ -1,5 +1,5 @@
/* Test for finite value (zero, subnormal, or normal, and not infinite or NaN).
Copyright (C) 2007-2014 Free Software Foundation, Inc.
Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Test for positive or negative infinity.
Copyright (C) 2007-2014 Free Software Foundation, Inc.
Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
Copyright (C) 2007-2014 Free Software Foundation, Inc.
Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
Copyright (C) 2007-2014 Free Software Foundation, Inc.
Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
Copyright (C) 2007-2014 Free Software Foundation, Inc.
Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
Copyright (C) 2007-2014 Free Software Foundation, Inc.
Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Replacement for 'int' to 'long double' conversion routine.
Copyright (C) 2011-2014 Free Software Foundation, Inc.
Copyright (C) 2011-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Substitute for and wrapper around <langinfo.h>.
Copyright (C) 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -49,7 +49,10 @@ typedef int nl_item;
# define CODESET 10000
/* nl_langinfo items of the LC_NUMERIC category */
# define RADIXCHAR 10001
# define DECIMAL_POINT RADIXCHAR
# define THOUSEP 10002
# define THOUSANDS_SEP THOUSEP
# define GROUPING 10114
/* nl_langinfo items of the LC_TIME category */
# define D_T_FMT 10003
# define D_FMT 10004
@ -102,6 +105,21 @@ typedef int nl_item;
# define ALT_DIGITS 10051
/* nl_langinfo items of the LC_MONETARY category */
# define CRNCYSTR 10052
# define CURRENCY_SYMBOL CRNCYSTR
# define INT_CURR_SYMBOL 10100
# define MON_DECIMAL_POINT 10101
# define MON_THOUSANDS_SEP 10102
# define MON_GROUPING 10103
# define POSITIVE_SIGN 10104
# define NEGATIVE_SIGN 10105
# define FRAC_DIGITS 10106
# define INT_FRAC_DIGITS 10107
# define P_CS_PRECEDES 10108
# define N_CS_PRECEDES 10109
# define P_SEP_BY_SPACE 10110
# define N_SEP_BY_SPACE 10111
# define P_SIGN_POSN 10112
# define N_SIGN_POSN 10113
/* nl_langinfo items of the LC_MESSAGES category */
# define YESEXPR 10053
# define NOEXPR 10054

View file

@ -1,6 +1,6 @@
/* Emulate link on platforms that lack it, namely native Windows platforms.
Copyright (C) 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* listen.c --- wrappers for Windows listen function
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* Determine a canonical name for the current locale's character encoding.
Copyright (C) 2000-2006, 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2000-2006, 2008-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -34,6 +34,7 @@
#if defined _WIN32 || defined __WIN32__
# define WINDOWS_NATIVE
# include <locale.h>
#endif
#if defined __EMX__
@ -127,7 +128,7 @@ get_charset_aliases (void)
cp = charset_aliases;
if (cp == NULL)
{
#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__)
#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__ || defined OS2)
const char *dir;
const char *base = "charset.alias";
char *file_name;
@ -341,6 +342,36 @@ get_charset_aliases (void)
"CP54936" "\0" "GB18030" "\0"
"CP65001" "\0" "UTF-8" "\0";
# endif
# if defined OS2
/* To avoid the troubles of installing a separate file in the same
directory as the DLL and of retrieving the DLL's directory at
runtime, simply inline the aliases here. */
/* The list of encodings is taken from "List of OS/2 Codepages"
by Alex Taylor:
<http://altsan.org/os2/toolkits/uls/index.html#codepages>.
See also "IBM Globalization - Code page identifiers":
<http://www-01.ibm.com/software/globalization/cp/cp_cpgid.html>. */
cp = "CP813" "\0" "ISO-8859-7" "\0"
"CP878" "\0" "KOI8-R" "\0"
"CP819" "\0" "ISO-8859-1" "\0"
"CP912" "\0" "ISO-8859-2" "\0"
"CP913" "\0" "ISO-8859-3" "\0"
"CP914" "\0" "ISO-8859-4" "\0"
"CP915" "\0" "ISO-8859-5" "\0"
"CP916" "\0" "ISO-8859-8" "\0"
"CP920" "\0" "ISO-8859-9" "\0"
"CP921" "\0" "ISO-8859-13" "\0"
"CP923" "\0" "ISO-8859-15" "\0"
"CP954" "\0" "EUC-JP" "\0"
"CP964" "\0" "EUC-TW" "\0"
"CP970" "\0" "EUC-KR" "\0"
"CP1089" "\0" "ISO-8859-6" "\0"
"CP1208" "\0" "UTF-8" "\0"
"CP1381" "\0" "GB2312" "\0"
"CP1386" "\0" "GBK" "\0"
"CP3372" "\0" "EUC-JP" "\0";
# endif
#endif
charset_aliases = cp;
@ -461,14 +492,34 @@ locale_charset (void)
static char buf[2 + 10 + 1];
/* The Windows API has a function returning the locale's codepage as a
number: GetACP().
When the output goes to a console window, it needs to be provided in
GetOEMCP() encoding if the console is using a raster font, or in
GetConsoleOutputCP() encoding if it is using a TrueType font.
But in GUI programs and for output sent to files and pipes, GetACP()
encoding is the best bet. */
sprintf (buf, "CP%u", GetACP ());
/* The Windows API has a function returning the locale's codepage as
a number, but the value doesn't change according to what the
'setlocale' call specified. So we use it as a last resort, in
case the string returned by 'setlocale' doesn't specify the
codepage. */
char *current_locale = setlocale (LC_ALL, NULL);
char *pdot;
/* If they set different locales for different categories,
'setlocale' will return a semi-colon separated list of locale
values. To make sure we use the correct one, we choose LC_CTYPE. */
if (strchr (current_locale, ';'))
current_locale = setlocale (LC_CTYPE, NULL);
pdot = strrchr (current_locale, '.');
if (pdot)
sprintf (buf, "CP%s", pdot + 1);
else
{
/* The Windows API has a function returning the locale's codepage as a
number: GetACP().
When the output goes to a console window, it needs to be provided in
GetOEMCP() encoding if the console is using a raster font, or in
GetConsoleOutputCP() encoding if it is using a TrueType font.
But in GUI programs and for output sent to files and pipes, GetACP()
encoding is the best bet. */
sprintf (buf, "CP%u", GetACP ());
}
codeset = buf;
#elif defined OS2
@ -478,6 +529,8 @@ locale_charset (void)
ULONG cp[3];
ULONG cplen;
codeset = NULL;
/* Allow user to override the codeset, as set in the operating system,
with standard language environment variables. */
locale = getenv ("LC_ALL");
@ -509,10 +562,12 @@ locale_charset (void)
}
}
/* Resolve through the charset.alias file. */
codeset = locale;
/* For the POSIX locale, don't use the system's codepage. */
if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0)
codeset = "";
}
else
if (codeset == NULL)
{
/* OS/2 has a function returning the locale's codepage as a number. */
if (DosQueryCp (sizeof (cp), cp, &cplen))

View file

@ -1,5 +1,5 @@
/* Determine a canonical name for the current locale's character encoding.
Copyright (C) 2000-2003, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2000-2003, 2009-2016 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
This program is free software; you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* A POSIX <locale.h>.
Copyright (C) 2007-2014 Free Software Foundation, Inc.
Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Query locale dependent information for formatting numbers.
Copyright (C) 2012-2014 Free Software Foundation, Inc.
Copyright (C) 2012-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Logarithm.
Copyright (C) 2012-2014 Free Software Foundation, Inc.
Copyright (C) 2012-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Natural logarithm of 1 plus argument.
Copyright (C) 2012-2014 Free Software Foundation, Inc.
Copyright (C) 2012-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* Work around a bug of lstat on some systems
Copyright (C) 1997-2006, 2008-2014 Free Software Foundation, Inc.
Copyright (C) 1997-2006, 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,6 +1,6 @@
/* malloc() function that is glibc compatible.
Copyright (C) 1997-1998, 2006-2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 1997-1998, 2006-2007, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,5 +1,5 @@
/* Safe automatic memory allocation.
Copyright (C) 2003, 2006-2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2003, 2006-2007, 2009-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Safe automatic memory allocation.
Copyright (C) 2003-2007, 2009-2014 Free Software Foundation, Inc.
Copyright (C) 2003-2007, 2009-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify

View file

@ -1,3 +1,4 @@
#include <config.h>
#define _GL_MATH_INLINE _GL_EXTERN_INLINE
#include "math.h"
typedef int dummy;

View file

@ -1,6 +1,6 @@
/* A GNU-like <math.h>.
Copyright (C) 2002-2003, 2007-2014 Free Software Foundation, Inc.
Copyright (C) 2002-2003, 2007-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -2205,7 +2205,8 @@ _GL_WARN_REAL_FLOATING_DECL (isnan);
#if @GNULIB_SIGNBIT@
# if @REPLACE_SIGNBIT_USING_GCC@
# if (@REPLACE_SIGNBIT_USING_GCC@ \
&& (!defined __cplusplus || __cplusplus < 201103))
# undef signbit
/* GCC 4.0 and newer provides three built-ins for signbit. */
# define signbit(x) \

View file

@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
Copyright (C) 1999-2002, 2005-2014 Free Software Foundation, Inc.
Copyright (C) 1999-2002, 2005-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@ -20,6 +20,11 @@
/* Specification. */
#include <wchar.h>
#if C_LOCALE_MAYBE_EILSEQ
# include "hard-locale.h"
# include <locale.h>
#endif
#if GNULIB_defined_mbstate_t
/* Implement mbrtowc() on top of mbtowc(). */
@ -328,7 +333,10 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
size_t
rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG
size_t ret;
wchar_t wc;
# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG
if (s == NULL)
{
pwc = NULL;
@ -337,6 +345,14 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
# endif
# if MBRTOWC_EMPTY_INPUT_BUG
if (n == 0)
return (size_t) -2;
# endif
if (! pwc)
pwc = &wc;
# if MBRTOWC_RETVAL_BUG
{
static mbstate_t internal_state;
@ -352,8 +368,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
size_t count = 0;
for (; n > 0; s++, n--)
{
wchar_t wc;
size_t ret = mbrtowc (&wc, s, 1, ps);
ret = mbrtowc (&wc, s, 1, ps);
if (ret == (size_t)(-1))
return (size_t)(-1);
@ -361,8 +376,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
if (ret != (size_t)(-2))
{
/* The multibyte character has been completed. */
if (pwc != NULL)
*pwc = wc;
*pwc = wc;
return (wc == 0 ? 0 : count);
}
}
@ -371,32 +385,23 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
# endif
ret = mbrtowc (pwc, s, n, ps);
# if MBRTOWC_NUL_RETVAL_BUG
{
wchar_t wc;
size_t ret = mbrtowc (&wc, s, n, ps);
if (ret != (size_t)(-1) && ret != (size_t)(-2))
{
if (pwc != NULL)
*pwc = wc;
if (wc == 0)
ret = 0;
}
return ret;
}
# else
{
# if MBRTOWC_NULL_ARG1_BUG
wchar_t dummy;
if (pwc == NULL)
pwc = &dummy;
# endif
return mbrtowc (pwc, s, n, ps);
}
if (ret < (size_t) -2 && !*pwc)
return 0;
# endif
# if C_LOCALE_MAYBE_EILSEQ
if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE))
{
unsigned char uc = *s;
*pwc = uc;
return 1;
}
# endif
return ret;
}
#endif

View file

@ -1,5 +1,5 @@
/* Test for initial conversion state.
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
Copyright (C) 2011-2014 Free Software Foundation, Inc.
Copyright (C) 2011-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
Copyright (C) 2011-2014 Free Software Foundation, Inc.
Copyright (C) 2011-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This program is free software: you can redistribute it and/or modify

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2014
/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2016
Free Software Foundation, Inc.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),

View file

@ -1,7 +1,7 @@
/* On some systems, mkdir ("foo/", 0700) fails because of the trailing
slash. On those systems, this wrapper removes the trailing slash.
Copyright (C) 2001, 2003, 2006, 2008-2014 Free Software Foundation, Inc.
Copyright (C) 2001, 2003, 2006, 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2014 Free Software
/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2016 Free Software
Foundation, Inc.
This file is derived from the one in the GNU C Library.

37
lib/mktime-internal.h Normal file
View file

@ -0,0 +1,37 @@
/* mktime variant that also uses an offset guess
Copyright 2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, see
<http://www.gnu.org/licenses/>. */
#include <time.h>
/* mktime_offset_t is a signed type wide enough to hold a UTC offset
in seconds, and used as part of the type of the offset-guess
argument to mktime_internal. Use time_t on platforms where time_t
is signed, to be compatible with platforms like BeOS that export
this implementation detail of mktime. On platforms where time_t is
unsigned, GNU and POSIX code can assume 'int' is at least 32 bits
which is wide enough for a UTC offset. */
#if TIME_T_IS_SIGNED
typedef time_t mktime_offset_t;
#else
typedef int mktime_offset_t;
#endif
time_t mktime_internal (struct tm *,
struct tm * (*) (time_t const *, struct tm *),
mktime_offset_t *);

630
lib/mktime.c Normal file
View file

@ -0,0 +1,630 @@
/* Convert a 'struct tm' to a time_t value.
Copyright (C) 1993-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Eggert <eggert@twinsun.com>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* Define this to 1 to have a standalone program to test this implementation of
mktime. */
#ifndef DEBUG_MKTIME
# define DEBUG_MKTIME 0
#endif
#if !defined _LIBC && !DEBUG_MKTIME
# include <config.h>
#endif
/* Assume that leap seconds are possible, unless told otherwise.
If the host has a 'zic' command with a '-L leapsecondfilename' option,
then it supports leap seconds; otherwise it probably doesn't. */
#ifndef LEAP_SECONDS_POSSIBLE
# define LEAP_SECONDS_POSSIBLE 1
#endif
#include <time.h>
#include <limits.h>
#include <stdbool.h>
#include <intprops.h>
#include <verify.h>
#if DEBUG_MKTIME
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
/* Make it work even if the system's libc has its own mktime routine. */
# undef mktime
# define mktime my_mktime
#endif
/* A signed type that can represent an integer number of years
multiplied by three times the number of seconds in a year. It is
needed when converting a tm_year value times the number of seconds
in a year. The factor of three comes because these products need
to be subtracted from each other, and sometimes with an offset
added to them, without worrying about overflow.
Much of the code uses long_int to represent time_t values, to
lessen the hassle of dealing with platforms where time_t is
unsigned, and because long_int should suffice to represent all
time_t values that mktime can generate even on platforms where
time_t is excessively wide. */
#if INT_MAX <= LONG_MAX / 3 / 366 / 24 / 60 / 60
typedef long int long_int;
#else
typedef long long int long_int;
#endif
verify (INT_MAX <= TYPE_MAXIMUM (long_int) / 3 / 366 / 24 / 60 / 60);
/* Shift A right by B bits portably, by dividing A by 2**B and
truncating towards minus infinity. B should be in the range 0 <= B
<= LONG_INT_BITS - 2, where LONG_INT_BITS is the number of useful
bits in a long_int. LONG_INT_BITS is at least 32.
ISO C99 says that A >> B is implementation-defined if A < 0. Some
implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
right in the usual way when A < 0, so SHR falls back on division if
ordinary A >> B doesn't seem to be the usual signed shift. */
static long_int
shr (long_int a, int b)
{
long_int one = 1;
return (-one >> 1 == -1
? a >> b
: a / (one << b) - (a % (one << b) < 0));
}
/* Bounds for the intersection of time_t and long_int. */
static long_int const mktime_min
= ((TYPE_SIGNED (time_t) && TYPE_MINIMUM (time_t) < TYPE_MINIMUM (long_int))
? TYPE_MINIMUM (long_int) : TYPE_MINIMUM (time_t));
static long_int const mktime_max
= (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (time_t)
? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (time_t));
verify (TYPE_IS_INTEGER (time_t));
#define EPOCH_YEAR 1970
#define TM_YEAR_BASE 1900
verify (TM_YEAR_BASE % 100 == 0);
/* Is YEAR + TM_YEAR_BASE a leap year? */
static bool
leapyear (long_int year)
{
/* Don't add YEAR to TM_YEAR_BASE, as that might overflow.
Also, work even if YEAR is negative. */
return
((year & 3) == 0
&& (year % 100 != 0
|| ((year / 100) & 3) == (- (TM_YEAR_BASE / 100) & 3)));
}
/* How many days come before each month (0-12). */
#ifndef _LIBC
static
#endif
const unsigned short int __mon_yday[2][13] =
{
/* Normal years. */
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
/* Leap years. */
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
};
#ifdef _LIBC
typedef time_t mktime_offset_t;
#else
/* Portable standalone applications should supply a <time.h> that
declares a POSIX-compliant localtime_r, for the benefit of older
implementations that lack localtime_r or have a nonstandard one.
See the gnulib time_r module for one way to implement this. */
# undef __localtime_r
# define __localtime_r localtime_r
# define __mktime_internal mktime_internal
# include "mktime-internal.h"
#endif
/* Do the values A and B differ according to the rules for tm_isdst?
A and B differ if one is zero and the other positive. */
static bool
isdst_differ (int a, int b)
{
return (!a != !b) && (0 <= a) && (0 <= b);
}
/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) -
(YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks
were not adjusted between the time stamps.
The YEAR values uses the same numbering as TP->tm_year. Values
need not be in the usual range. However, YEAR1 must not overflow
when multiplied by three times the number of seconds in a year, and
likewise for YDAY1 and three times the number of seconds in a day. */
static long_int
ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1,
int year0, int yday0, int hour0, int min0, int sec0)
{
verify (-1 / 2 == 0);
/* Compute intervening leap days correctly even if year is negative.
Take care to avoid integer overflow here. */
int a4 = shr (year1, 2) + shr (TM_YEAR_BASE, 2) - ! (year1 & 3);
int b4 = shr (year0, 2) + shr (TM_YEAR_BASE, 2) - ! (year0 & 3);
int a100 = a4 / 25 - (a4 % 25 < 0);
int b100 = b4 / 25 - (b4 % 25 < 0);
int a400 = shr (a100, 2);
int b400 = shr (b100, 2);
int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
/* Compute the desired time without overflowing. */
long_int years = year1 - year0;
long_int days = 365 * years + yday1 - yday0 + intervening_leap_days;
long_int hours = 24 * days + hour1 - hour0;
long_int minutes = 60 * hours + min1 - min0;
long_int seconds = 60 * minutes + sec1 - sec0;
return seconds;
}
/* Return the average of A and B, even if A + B would overflow.
Round toward positive infinity. */
static long_int
long_int_avg (long_int a, long_int b)
{
return shr (a, 1) + shr (b, 1) + ((a | b) & 1);
}
/* Return a time_t value corresponding to (YEAR-YDAY HOUR:MIN:SEC),
assuming that T corresponds to *TP and that no clock adjustments
occurred between *TP and the desired time.
Although T and the returned value are of type long_int,
they represent time_t values and must be in time_t range.
If TP is null, return a value not equal to T; this avoids false matches.
YEAR and YDAY must not be so large that multiplying them by three times the
number of seconds in a year (or day, respectively) would overflow long_int.
If the returned value would be out of range, yield the minimal or
maximal in-range value, except do not yield a value equal to T. */
static long_int
guess_time_tm (long_int year, long_int yday, int hour, int min, int sec,
long_int t, const struct tm *tp)
{
if (tp)
{
long_int result;
long_int d = ydhms_diff (year, yday, hour, min, sec,
tp->tm_year, tp->tm_yday,
tp->tm_hour, tp->tm_min, tp->tm_sec);
if (! INT_ADD_WRAPV (t, d, &result))
return result;
}
/* Overflow occurred one way or another. Return the nearest result
that is actually in range, except don't report a zero difference
if the actual difference is nonzero, as that would cause a false
match; and don't oscillate between two values, as that would
confuse the spring-forward gap detector. */
return (t < long_int_avg (mktime_min, mktime_max)
? (t <= mktime_min + 1 ? t + 1 : mktime_min)
: (mktime_max - 1 <= t ? t - 1 : mktime_max));
}
/* Use CONVERT to convert T to a struct tm value in *TM. T must be in
range for time_t. Return TM if successful, NULL if T is out of
range for CONVERT. */
static struct tm *
convert_time (struct tm *(*convert) (const time_t *, struct tm *),
long_int t, struct tm *tm)
{
time_t x = t;
return convert (&x, tm);
}
/* Use CONVERT to convert *T to a broken down time in *TP.
If *T is out of range for conversion, adjust it so that
it is the nearest in-range value and then convert that.
A value is in range if it fits in both time_t and long_int. */
static struct tm *
ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
long_int *t, struct tm *tp)
{
struct tm *r;
if (*t < mktime_min)
*t = mktime_min;
else if (mktime_max < *t)
*t = mktime_max;
r = convert_time (convert, *t, tp);
if (!r && *t)
{
long_int bad = *t;
long_int ok = 0;
/* BAD is a known unconvertible value, and OK is a known good one.
Use binary search to narrow the range between BAD and OK until
they differ by 1. */
while (true)
{
long_int mid = long_int_avg (ok, bad);
if (mid != ok && mid != bad)
break;
r = convert_time (convert, mid, tp);
if (r)
ok = mid;
else
bad = mid;
}
if (!r && ok)
{
/* The last conversion attempt failed;
revert to the most recent successful attempt. */
r = convert_time (convert, ok, tp);
}
}
return r;
}
/* Convert *TP to a time_t value, inverting
the monotonic and mostly-unit-linear conversion function CONVERT.
Use *OFFSET to keep track of a guess at the offset of the result,
compared to what the result would be for UTC without leap seconds.
If *OFFSET's guess is correct, only one CONVERT call is needed.
This function is external because it is used also by timegm.c. */
time_t
__mktime_internal (struct tm *tp,
struct tm *(*convert) (const time_t *, struct tm *),
mktime_offset_t *offset)
{
long_int t, gt, t0, t1, t2, dt;
struct tm tm;
/* The maximum number of probes (calls to CONVERT) should be enough
to handle any combinations of time zone rule changes, solar time,
leap seconds, and oscillations around a spring-forward gap.
POSIX.1 prohibits leap seconds, but some hosts have them anyway. */
int remaining_probes = 6;
/* Time requested. Copy it in case CONVERT modifies *TP; this can
occur if TP is localtime's returned value and CONVERT is localtime. */
int sec = tp->tm_sec;
int min = tp->tm_min;
int hour = tp->tm_hour;
int mday = tp->tm_mday;
int mon = tp->tm_mon;
int year_requested = tp->tm_year;
int isdst = tp->tm_isdst;
/* 1 if the previous probe was DST. */
int dst2;
/* Ensure that mon is in range, and set year accordingly. */
int mon_remainder = mon % 12;
int negative_mon_remainder = mon_remainder < 0;
int mon_years = mon / 12 - negative_mon_remainder;
long_int lyear_requested = year_requested;
long_int year = lyear_requested + mon_years;
/* The other values need not be in range:
the remaining code handles overflows correctly. */
/* Calculate day of year from year, month, and day of month.
The result need not be in range. */
int mon_yday = ((__mon_yday[leapyear (year)]
[mon_remainder + 12 * negative_mon_remainder])
- 1);
long_int lmday = mday;
long_int yday = mon_yday + lmday;
int negative_offset_guess;
int sec_requested = sec;
if (LEAP_SECONDS_POSSIBLE)
{
/* Handle out-of-range seconds specially,
since ydhms_tm_diff assumes every minute has 60 seconds. */
if (sec < 0)
sec = 0;
if (59 < sec)
sec = 59;
}
/* Invert CONVERT by probing. First assume the same offset as last
time. */
INT_SUBTRACT_WRAPV (0, *offset, &negative_offset_guess);
t0 = ydhms_diff (year, yday, hour, min, sec,
EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, negative_offset_guess);
/* Repeatedly use the error to improve the guess. */
for (t = t1 = t2 = t0, dst2 = 0;
(gt = guess_time_tm (year, yday, hour, min, sec, t,
ranged_convert (convert, &t, &tm)),
t != gt);
t1 = t2, t2 = t, t = gt, dst2 = tm.tm_isdst != 0)
if (t == t1 && t != t2
&& (tm.tm_isdst < 0
|| (isdst < 0
? dst2 <= (tm.tm_isdst != 0)
: (isdst != 0) != (tm.tm_isdst != 0))))
/* We can't possibly find a match, as we are oscillating
between two values. The requested time probably falls
within a spring-forward gap of size GT - T. Follow the common
practice in this case, which is to return a time that is GT - T
away from the requested time, preferring a time whose
tm_isdst differs from the requested value. (If no tm_isdst
was requested and only one of the two values has a nonzero
tm_isdst, prefer that value.) In practice, this is more
useful than returning -1. */
goto offset_found;
else if (--remaining_probes == 0)
return -1;
/* We have a match. Check whether tm.tm_isdst has the requested
value, if any. */
if (isdst_differ (isdst, tm.tm_isdst))
{
/* tm.tm_isdst has the wrong value. Look for a neighboring
time with the right value, and use its UTC offset.
Heuristic: probe the adjacent timestamps in both directions,
looking for the desired isdst. This should work for all real
time zone histories in the tz database. */
/* Distance between probes when looking for a DST boundary. In
tzdata2003a, the shortest period of DST is 601200 seconds
(e.g., America/Recife starting 2000-10-08 01:00), and the
shortest period of non-DST surrounded by DST is 694800
seconds (Africa/Tunis starting 1943-04-17 01:00). Use the
minimum of these two values, so we don't miss these short
periods when probing. */
int stride = 601200;
/* The longest period of DST in tzdata2003a is 536454000 seconds
(e.g., America/Jujuy starting 1946-10-01 01:00). The longest
period of non-DST is much longer, but it makes no real sense
to search for more than a year of non-DST, so use the DST
max. */
int duration_max = 536454000;
/* Search in both directions, so the maximum distance is half
the duration; add the stride to avoid off-by-1 problems. */
int delta_bound = duration_max / 2 + stride;
int delta, direction;
for (delta = stride; delta < delta_bound; delta += stride)
for (direction = -1; direction <= 1; direction += 2)
{
long_int ot;
if (! INT_ADD_WRAPV (t, delta * direction, &ot))
{
struct tm otm;
ranged_convert (convert, &ot, &otm);
if (! isdst_differ (isdst, otm.tm_isdst))
{
/* We found the desired tm_isdst.
Extrapolate back to the desired time. */
t = guess_time_tm (year, yday, hour, min, sec, ot, &otm);
ranged_convert (convert, &t, &tm);
goto offset_found;
}
}
}
}
offset_found:
/* Set *OFFSET to the low-order bits of T - T0 - NEGATIVE_OFFSET_GUESS.
This is just a heuristic to speed up the next mktime call, and
correctness is unaffected if integer overflow occurs here. */
INT_SUBTRACT_WRAPV (t, t0, &dt);
INT_SUBTRACT_WRAPV (dt, negative_offset_guess, offset);
if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec)
{
/* Adjust time to reflect the tm_sec requested, not the normalized value.
Also, repair any damage from a false match due to a leap second. */
long_int sec_adjustment = sec == 0 && tm.tm_sec == 60;
sec_adjustment -= sec;
sec_adjustment += sec_requested;
if (INT_ADD_WRAPV (t, sec_adjustment, &t)
|| ! (mktime_min <= t && t <= mktime_max)
|| ! convert_time (convert, t, &tm))
return -1;
}
*tp = tm;
return t;
}
static mktime_offset_t localtime_offset;
/* Convert *TP to a time_t value. */
time_t
mktime (struct tm *tp)
{
#ifdef _LIBC
/* POSIX.1 8.1.1 requires that whenever mktime() is called, the
time zone names contained in the external variable 'tzname' shall
be set as if the tzset() function had been called. */
__tzset ();
#elif HAVE_TZSET
tzset ();
#endif
return __mktime_internal (tp, __localtime_r, &localtime_offset);
}
#ifdef weak_alias
weak_alias (mktime, timelocal)
#endif
#ifdef _LIBC
libc_hidden_def (mktime)
libc_hidden_weak (timelocal)
#endif
#if DEBUG_MKTIME
static int
not_equal_tm (const struct tm *a, const struct tm *b)
{
return ((a->tm_sec ^ b->tm_sec)
| (a->tm_min ^ b->tm_min)
| (a->tm_hour ^ b->tm_hour)
| (a->tm_mday ^ b->tm_mday)
| (a->tm_mon ^ b->tm_mon)
| (a->tm_year ^ b->tm_year)
| (a->tm_yday ^ b->tm_yday)
| isdst_differ (a->tm_isdst, b->tm_isdst));
}
static void
print_tm (const struct tm *tp)
{
if (tp)
printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d",
tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday,
tp->tm_hour, tp->tm_min, tp->tm_sec,
tp->tm_yday, tp->tm_wday, tp->tm_isdst);
else
printf ("0");
}
static int
check_result (time_t tk, struct tm tmk, time_t tl, const struct tm *lt)
{
if (tk != tl || !lt || not_equal_tm (&tmk, lt))
{
printf ("mktime (");
print_tm (lt);
printf (")\nyields (");
print_tm (&tmk);
printf (") == %ld, should be %ld\n", (long int) tk, (long int) tl);
return 1;
}
return 0;
}
int
main (int argc, char **argv)
{
int status = 0;
struct tm tm, tmk, tml;
struct tm *lt;
time_t tk, tl, tl1;
char trailer;
/* Sanity check, plus call tzset. */
tl = 0;
if (! localtime (&tl))
{
printf ("localtime (0) fails\n");
status = 1;
}
if ((argc == 3 || argc == 4)
&& (sscanf (argv[1], "%d-%d-%d%c",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer)
== 3)
&& (sscanf (argv[2], "%d:%d:%d%c",
&tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer)
== 3))
{
tm.tm_year -= TM_YEAR_BASE;
tm.tm_mon--;
tm.tm_isdst = argc == 3 ? -1 : atoi (argv[3]);
tmk = tm;
tl = mktime (&tmk);
lt = localtime_r (&tl, &tml);
printf ("mktime returns %ld == ", (long int) tl);
print_tm (&tmk);
printf ("\n");
status = check_result (tl, tmk, tl, lt);
}
else if (argc == 4 || (argc == 5 && strcmp (argv[4], "-") == 0))
{
time_t from = atol (argv[1]);
time_t by = atol (argv[2]);
time_t to = atol (argv[3]);
if (argc == 4)
for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
{
lt = localtime_r (&tl, &tml);
if (lt)
{
tmk = tml;
tk = mktime (&tmk);
status |= check_result (tk, tmk, tl, &tml);
}
else
{
printf ("localtime_r (%ld) yields 0\n", (long int) tl);
status = 1;
}
tl1 = tl + by;
if ((tl1 < tl) != (by < 0))
break;
}
else
for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
{
/* Null benchmark. */
lt = localtime_r (&tl, &tml);
if (lt)
{
tmk = tml;
tk = tl;
status |= check_result (tk, tmk, tl, &tml);
}
else
{
printf ("localtime_r (%ld) yields 0\n", (long int) tl);
status = 1;
}
tl1 = tl + by;
if ((tl1 < tl) != (by < 0))
break;
}
}
else
printf ("Usage:\
\t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\
\t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\
\t%s FROM BY TO - # Do not test those values (for benchmark).\n",
argv[0], argv[0], argv[0]);
return status;
}
#endif /* DEBUG_MKTIME */
/*
Local Variables:
compile-command: "gcc -DDEBUG_MKTIME -I. -Wall -W -O2 -g mktime.c -o mktime"
End:
*/

Some files were not shown because too many files have changed in this diff Show more