update gnulib to 47bf2cf3184027c1eb9c1dfeea5c5b8b2d69710d
* lib/dosname.h, lib/glthread/lock.c, lib/glthread/lock.h, lib/glthread/threadlib.c, lib/windows-mutex.c, lib/windows-mutex.h, lib/windows-once.c, lib/windows-once.h, lib/windows-recmutex.c, lib/windows-recmutex.h, lib/windows-rwlock.c, lib/windows-rwlock.h, m4/host-cpu-c-abi.m4, m4/lib-ld.m4, m4/lib-link.m4, m4/lib-prefix.m4, m4/lock.m4, m4/longlong.m4, m4/pthread_rwlock_rdlock.m4, tools/config.rpath: Delete. * lib/alloca.in.h, lib/argmatch.c, lib/argmatch.h, lib/arg-nonnull.h, lib/argp-ba.c, lib/argp-eexst.c, lib/argp-fmtstream.c, lib/argp-fmtstream.h, lib/argp-fs-xinl.c, lib/argp.h, lib/argp-help.c, lib/argp-namefrob.h, lib/argp-parse.c, lib/argp-pin.c, lib/argp-pv.c, lib/argp-pvh.c, lib/argp-xinl.c, lib/asnprintf.c, lib/basename-lgpl.c, lib/c-ctype.h, lib/c++defs.h, lib/cdefs.h, lib/closeout.c, lib/closeout.h, lib/close-stream.c, lib/c-strcasecmp.c, lib/c-strcaseeq.h, lib/c-strcase.h, lib/c-strncasecmp.c, lib/dirname.h, lib/dirname-lgpl.c, lib/errno.in.h, lib/error.c, lib/error.h, lib/exitfail.c, lib/exitfail.h, lib/fcntl.in.h, lib/filename.h, lib/float.c, lib/float+.h, lib/float.in.h, lib/fpending.c, lib/fpending.h, lib/getopt1.c, lib/getopt.c, lib/getopt-cdefs.in.h, lib/getopt-core.h, lib/getopt-ext.h, lib/getopt.in.h, lib/getopt_int.h, lib/getopt-pfx-core.h, lib/getopt-pfx-ext.h, lib/getprogname.c, lib/getprogname.h, lib/gettext.h, lib/gettimeofday.c, lib/hard-locale.c, lib/hard-locale.h, lib/intprops.h, lib/isatty.c, lib/itold.c, lib/libc-config.h, lib/limits.in.h, lib/localcharset.c, lib/localcharset.h, lib/localtime-buffer.c, lib/localtime-buffer.h, lib/lstat.c, lib/Makefile.am, lib/malloca.c, lib/malloca.h, lib/malloc.c, lib/mbrtowc.c, lib/mbsinit.c, lib/memchr.c, lib/memchr.valgrind, lib/mempcpy.c, lib/minmax.h, lib/mkdir.c, lib/mkstemp.c, lib/mkstemps.c, lib/msvc-inval.c, lib/msvc-inval.h, lib/msvc-nothrow.c, lib/msvc-nothrow.h, lib/_Noreturn.h, lib/pathmax.h, lib/printf-args.c, lib/printf-args.h, lib/printf-parse.c, lib/printf-parse.h, lib/progname.c, lib/progname.h, lib/quotearg.c, lib/quotearg.h, lib/quote.h, lib/rawmemchr.c, lib/rawmemchr.valgrind, lib/secure_getenv.c, lib/size_max.h, lib/sleep.c, lib/stat.c, lib/stat-time.h, lib/stat-w32.c, lib/stat-w32.h, lib/stdalign.in.h, lib/stdbool.in.h, lib/stddef.in.h, lib/stdint.in.h, lib/stdio-impl.h, lib/stdio.in.h, lib/stdlib.in.h, lib/stpcpy.c, lib/strcasecmp.c, lib/strchrnul.c, lib/strchrnul.valgrind, lib/streq.h, lib/strerror.c, lib/strerror-override.c, lib/strerror-override.h, lib/string.in.h, lib/strings.in.h, lib/stripslash.c, lib/strncasecmp.c, lib/strndup.c, lib/strnlen.c, lib/strverscmp.c, lib/sysexits.in.h, lib/sys_stat.in.h, lib/sys_time.in.h, lib/sys_types.in.h, lib/sys_wait.in.h, lib/tempname.c, lib/tempname.h, lib/time.in.h, lib/unistd.in.h, lib/vasnprintf.c, lib/vasnprintf.h, lib/verify.h, lib/vsnprintf.c, lib/warn-on-use.h, lib/wchar.in.h, lib/wctype.in.h, lib/windows-initguard.h, lib/xalloc-die.c, lib/xalloc.h, lib/xalloc-oversized.h, lib/xmalloc.c, lib/xsize.h, m4/00gnulib.m4, m4/absolute-header.m4, m4/alloca.m4, m4/argp.m4, m4/codeset.m4, m4/dirname.m4, m4/double-slash-root.m4, m4/eealloc.m4, m4/errno_h.m4, m4/error.m4, m4/exponentd.m4, m4/extensions.m4, m4/extern-inline.m4, m4/fcntl_h.m4, m4/fcntl-o.m4, m4/float_h.m4, m4/fpending.m4, m4/getopt.m4, m4/getprogname.m4, m4/gettimeofday.m4, m4/gnulib-cache.m4, m4/gnulib-common.m4, m4/gnulib-comp.m4, m4/gnulib-tool.m4, m4/include_next.m4, m4/__inline.m4, m4/intmax_t.m4, m4/inttypes_h.m4, m4/isatty.m4, m4/largefile.m4, m4/limits-h.m4, m4/localcharset.m4, m4/locale-fr.m4, m4/locale-ja.m4, m4/locale-zh.m4, m4/localtime-buffer.m4, m4/lstat.m4, m4/malloca.m4, m4/malloc.m4, m4/math_h.m4, m4/mbrtowc.m4, m4/mbsinit.m4, m4/mbstate_t.m4, m4/memchr.m4, m4/mempcpy.m4, m4/minmax.m4, m4/mkdir.m4, m4/mkstemp.m4, m4/mkstemps.m4, m4/mmap-anon.m4, m4/msvc-inval.m4, m4/msvc-nothrow.m4, m4/multiarch.m4, m4/nocrash.m4, m4/off_t.m4, m4/pathmax.m4, m4/printf.m4, m4/quotearg.m4, m4/quote.m4, m4/rawmemchr.m4, m4/secure_getenv.m4, m4/size_max.m4, m4/sleep.m4, m4/ssize_t.m4, m4/stat.m4, m4/stat-time.m4, m4/stdalign.m4, m4/stdbool.m4, m4/stddef_h.m4, m4/std-gnu11.m4, m4/stdint_h.m4, m4/stdint.m4, m4/stdio_h.m4, m4/stdlib_h.m4, m4/stpcpy.m4, m4/strcase.m4, m4/strchrnul.m4, m4/strerror.m4, m4/string_h.m4, m4/strings_h.m4, m4/strndup.m4, m4/strnlen.m4, m4/strverscmp.m4, m4/sysexits.m4, m4/sys_socket_h.m4, m4/sys_stat_h.m4, m4/sys_time_h.m4, m4/sys_types_h.m4, m4/sys_wait_h.m4, m4/tempname.m4, m4/threadlib.m4, m4/time_h.m4, m4/unistd_h.m4, m4/vasnprintf.m4, m4/vsnprintf.m4, m4/warn-on-use.m4, m4/wchar_h.m4, m4/wchar_t.m4, m4/wctype_h.m4, m4/wint_t.m4, m4/xalloc.m4, m4/xsize.m4: Update. * lib/inttypes.in.h, lib/lc-charset-dispatch.c, lib/lc-charset-dispatch.h, lib/locale.in.h, lib/mbrtowc-impl.h, lib/mbrtowc-impl-utf8.h, lib/mbtowc-lock.c, lib/mbtowc-lock.h, lib/setlocale-lock.c, lib/setlocale_null.c, lib/setlocale_null.h, m4/inttypes.m4, m4/locale_h.m4, m4/setlocale_null.m4, m4/visibility.m4, m4/zzgnulib.m4: New files.
This commit is contained in:
parent
fe642bc9ad
commit
1e86463205
287 changed files with 6133 additions and 6812 deletions
186
lib/Makefile.am
186
lib/Makefile.am
|
|
@ -1,6 +1,6 @@
|
|||
## DO NOT EDIT! GENERATED AUTOMATICALLY!
|
||||
## Process this file with automake to produce Makefile.in.
|
||||
# Copyright (C) 2002-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2020 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
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
# strverscmp \
|
||||
# sys_wait
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.11 gnits subdir-objects
|
||||
AUTOMAKE_OPTIONS = 1.11 gnits
|
||||
|
||||
SUBDIRS =
|
||||
noinst_HEADERS =
|
||||
|
|
@ -73,8 +73,10 @@ libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS)
|
|||
EXTRA_libgnu_la_SOURCES =
|
||||
libgnu_la_LDFLAGS = $(AM_LDFLAGS)
|
||||
libgnu_la_LDFLAGS += -no-undefined
|
||||
libgnu_la_LDFLAGS += $(LIB_HARD_LOCALE)
|
||||
libgnu_la_LDFLAGS += $(LIB_MBRTOWC)
|
||||
libgnu_la_LDFLAGS += $(LIB_SETLOCALE_NULL)
|
||||
libgnu_la_LDFLAGS += $(LTLIBINTL)
|
||||
libgnu_la_LDFLAGS += $(LTLIBTHREAD)
|
||||
|
||||
## begin gnulib module absolute-header
|
||||
|
||||
|
|
@ -176,13 +178,6 @@ EXTRA_DIST += dirname.h
|
|||
|
||||
## end gnulib module dirname-lgpl
|
||||
|
||||
## begin gnulib module dosname
|
||||
|
||||
|
||||
EXTRA_DIST += dosname.h
|
||||
|
||||
## end gnulib module dosname
|
||||
|
||||
## begin gnulib module errno
|
||||
|
||||
BUILT_SOURCES += $(ERRNO_H)
|
||||
|
|
@ -248,12 +243,14 @@ fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
|
|||
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||
-e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
|
||||
-e 's/@''GNULIB_CREAT''@/$(GNULIB_CREAT)/g' \
|
||||
-e 's/@''GNULIB_FCNTL''@/$(GNULIB_FCNTL)/g' \
|
||||
-e 's/@''GNULIB_NONBLOCKING''@/$(GNULIB_NONBLOCKING)/g' \
|
||||
-e 's/@''GNULIB_OPEN''@/$(GNULIB_OPEN)/g' \
|
||||
-e 's/@''GNULIB_OPENAT''@/$(GNULIB_OPENAT)/g' \
|
||||
-e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
|
||||
-e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
|
||||
-e 's|@''REPLACE_CREAT''@|$(REPLACE_CREAT)|g' \
|
||||
-e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
|
||||
-e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
|
||||
-e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \
|
||||
|
|
@ -381,13 +378,6 @@ EXTRA_DIST += hard-locale.h
|
|||
|
||||
## end gnulib module hard-locale
|
||||
|
||||
## begin gnulib module havelib
|
||||
|
||||
|
||||
EXTRA_DIST += $(top_srcdir)/tools/config.rpath
|
||||
|
||||
## end gnulib module havelib
|
||||
|
||||
## begin gnulib module intprops
|
||||
|
||||
|
||||
|
|
@ -395,6 +385,50 @@ EXTRA_DIST += intprops.h
|
|||
|
||||
## end gnulib module intprops
|
||||
|
||||
## begin gnulib module inttypes-incomplete
|
||||
|
||||
BUILT_SOURCES += inttypes.h
|
||||
|
||||
# We need the following in order to create <inttypes.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
|
||||
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||
-e 's|@''NEXT_INTTYPES_H''@|$(NEXT_INTTYPES_H)|g' \
|
||||
-e 's/@''PRI_MACROS_BROKEN''@/$(PRI_MACROS_BROKEN)/g' \
|
||||
-e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
|
||||
-e 's/@''PRIPTR_PREFIX''@/$(PRIPTR_PREFIX)/g' \
|
||||
-e 's/@''GNULIB_IMAXABS''@/$(GNULIB_IMAXABS)/g' \
|
||||
-e 's/@''GNULIB_IMAXDIV''@/$(GNULIB_IMAXDIV)/g' \
|
||||
-e 's/@''GNULIB_STRTOIMAX''@/$(GNULIB_STRTOIMAX)/g' \
|
||||
-e 's/@''GNULIB_STRTOUMAX''@/$(GNULIB_STRTOUMAX)/g' \
|
||||
-e 's/@''HAVE_DECL_IMAXABS''@/$(HAVE_DECL_IMAXABS)/g' \
|
||||
-e 's/@''HAVE_DECL_IMAXDIV''@/$(HAVE_DECL_IMAXDIV)/g' \
|
||||
-e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
|
||||
-e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
|
||||
-e 's/@''HAVE_IMAXDIV_T''@/$(HAVE_IMAXDIV_T)/g' \
|
||||
-e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \
|
||||
-e 's/@''REPLACE_STRTOUMAX''@/$(REPLACE_STRTOUMAX)/g' \
|
||||
-e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \
|
||||
-e 's/@''INT64_MAX_EQ_LONG_MAX''@/$(INT64_MAX_EQ_LONG_MAX)/g' \
|
||||
-e 's/@''UINT32_MAX_LT_UINTMAX_MAX''@/$(UINT32_MAX_LT_UINTMAX_MAX)/g' \
|
||||
-e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/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)' \
|
||||
< $(srcdir)/inttypes.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += inttypes.h inttypes.h-t
|
||||
|
||||
EXTRA_DIST += inttypes.in.h
|
||||
|
||||
## end gnulib module inttypes-incomplete
|
||||
|
||||
## begin gnulib module isatty
|
||||
|
||||
|
||||
|
|
@ -447,6 +481,47 @@ EXTRA_DIST += localcharset.h
|
|||
|
||||
## end gnulib module localcharset
|
||||
|
||||
## begin gnulib module locale
|
||||
|
||||
BUILT_SOURCES += locale.h
|
||||
|
||||
# We need the following in order to create <locale.h> when the system
|
||||
# doesn't have one that provides all definitions.
|
||||
locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
|
||||
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||
-e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
|
||||
-e 's/@''GNULIB_LOCALECONV''@/$(GNULIB_LOCALECONV)/g' \
|
||||
-e 's/@''GNULIB_SETLOCALE''@/$(GNULIB_SETLOCALE)/g' \
|
||||
-e 's/@''GNULIB_SETLOCALE_NULL''@/$(GNULIB_SETLOCALE_NULL)/g' \
|
||||
-e 's/@''GNULIB_DUPLOCALE''@/$(GNULIB_DUPLOCALE)/g' \
|
||||
-e 's/@''GNULIB_LOCALENAME''@/$(GNULIB_LOCALENAME)/g' \
|
||||
-e 's|@''HAVE_NEWLOCALE''@|$(HAVE_NEWLOCALE)|g' \
|
||||
-e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \
|
||||
-e 's|@''HAVE_FREELOCALE''@|$(HAVE_FREELOCALE)|g' \
|
||||
-e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
|
||||
-e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \
|
||||
-e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \
|
||||
-e 's|@''REPLACE_NEWLOCALE''@|$(REPLACE_NEWLOCALE)|g' \
|
||||
-e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
|
||||
-e 's|@''REPLACE_FREELOCALE''@|$(REPLACE_FREELOCALE)|g' \
|
||||
-e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|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)' \
|
||||
< $(srcdir)/locale.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += locale.h locale.h-t
|
||||
|
||||
EXTRA_DIST += locale.in.h
|
||||
|
||||
## end gnulib module locale
|
||||
|
||||
## begin gnulib module localtime-buffer
|
||||
|
||||
|
||||
|
|
@ -456,12 +531,6 @@ EXTRA_libgnu_la_SOURCES += localtime-buffer.c
|
|||
|
||||
## end gnulib module localtime-buffer
|
||||
|
||||
## begin gnulib module lock
|
||||
|
||||
libgnu_la_SOURCES += glthread/lock.h glthread/lock.c
|
||||
|
||||
## end gnulib module lock
|
||||
|
||||
## begin gnulib module lstat
|
||||
|
||||
|
||||
|
|
@ -500,9 +569,9 @@ EXTRA_DIST += malloca.h
|
|||
## begin gnulib module mbrtowc
|
||||
|
||||
|
||||
EXTRA_DIST += mbrtowc.c
|
||||
EXTRA_DIST += lc-charset-dispatch.c lc-charset-dispatch.h mbrtowc-impl-utf8.h mbrtowc-impl.h mbrtowc.c mbtowc-lock.c mbtowc-lock.h windows-initguard.h
|
||||
|
||||
EXTRA_libgnu_la_SOURCES += mbrtowc.c
|
||||
EXTRA_libgnu_la_SOURCES += lc-charset-dispatch.c mbrtowc.c mbtowc-lock.c
|
||||
|
||||
## end gnulib module mbrtowc
|
||||
|
||||
|
|
@ -630,6 +699,16 @@ EXTRA_libgnu_la_SOURCES += secure_getenv.c
|
|||
|
||||
## end gnulib module secure_getenv
|
||||
|
||||
## begin gnulib module setlocale-null
|
||||
|
||||
libgnu_la_SOURCES += setlocale_null.c
|
||||
|
||||
EXTRA_DIST += setlocale-lock.c setlocale_null.h windows-initguard.h
|
||||
|
||||
EXTRA_libgnu_la_SOURCES += setlocale-lock.c
|
||||
|
||||
## end gnulib module setlocale-null
|
||||
|
||||
## begin gnulib module size_max
|
||||
|
||||
libgnu_la_SOURCES += size_max.h
|
||||
|
|
@ -809,8 +888,6 @@ stdint.h: stdint.in.h $(top_builddir)/config.status
|
|||
-e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
|
||||
-e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
|
||||
-e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
|
||||
-e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
|
||||
-e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
|
||||
-e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
|
||||
-e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
|
||||
-e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
|
||||
|
|
@ -1340,6 +1417,7 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
|
|||
-e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
|
||||
-e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
|
||||
-e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
|
||||
-e 's|@''REPLACE_FCHMODAT''@|$(REPLACE_FCHMODAT)|g' \
|
||||
-e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
|
||||
-e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
|
||||
-e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
|
||||
|
|
@ -1487,14 +1565,6 @@ EXTRA_DIST += tempname.h
|
|||
|
||||
## end gnulib module tempname
|
||||
|
||||
## begin gnulib module threadlib
|
||||
|
||||
libgnu_la_SOURCES += glthread/threadlib.c
|
||||
|
||||
EXTRA_DIST += $(top_srcdir)/tools/config.rpath
|
||||
|
||||
## end gnulib module threadlib
|
||||
|
||||
## begin gnulib module time
|
||||
|
||||
BUILT_SOURCES += time.h
|
||||
|
|
@ -1567,6 +1637,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
|
|||
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||
-e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
|
||||
-e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
|
||||
-e 's/@''GNULIB_ACCESS''@/$(GNULIB_ACCESS)/g' \
|
||||
-e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \
|
||||
-e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \
|
||||
-e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \
|
||||
|
|
@ -1589,6 +1660,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
|
|||
-e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \
|
||||
-e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \
|
||||
-e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \
|
||||
-e 's/@''GNULIB_GETOPT_POSIX''@/$(GNULIB_GETOPT_POSIX)/g' \
|
||||
-e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \
|
||||
-e 's/@''GNULIB_GETPASS''@/$(GNULIB_GETPASS)/g' \
|
||||
-e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \
|
||||
|
|
@ -1666,7 +1738,8 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
|
|||
-e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
|
||||
-e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
|
||||
| \
|
||||
sed -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
|
||||
sed -e 's|@''REPLACE_ACCESS''@|$(REPLACE_ACCESS)|g' \
|
||||
-e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
|
||||
-e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
|
||||
-e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
|
||||
-e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
|
||||
|
|
@ -1853,6 +1926,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
|
|||
-e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
|
||||
-e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
|
||||
-e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \
|
||||
-e 's|@''REPLACE_WCSTOK''@|$(REPLACE_WCSTOK)|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)'; \
|
||||
|
|
@ -1883,6 +1957,8 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
|
|||
-e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \
|
||||
-e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
|
||||
-e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \
|
||||
-e 's/@''GNULIB_ISWDIGIT''@/$(GNULIB_ISWDIGIT)/g' \
|
||||
-e 's/@''GNULIB_ISWXDIGIT''@/$(GNULIB_ISWXDIGIT)/g' \
|
||||
-e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \
|
||||
-e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \
|
||||
-e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \
|
||||
|
|
@ -1893,6 +1969,8 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
|
|||
-e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \
|
||||
-e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
|
||||
-e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \
|
||||
-e 's/@''REPLACE_ISWDIGIT''@/$(REPLACE_ISWDIGIT)/g' \
|
||||
-e 's/@''REPLACE_ISWXDIGIT''@/$(REPLACE_ISWXDIGIT)/g' \
|
||||
-e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
|
||||
-e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \
|
||||
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
|
||||
|
|
@ -1906,42 +1984,6 @@ EXTRA_DIST += wctype.in.h
|
|||
|
||||
## end gnulib module wctype-h
|
||||
|
||||
## begin gnulib module windows-mutex
|
||||
|
||||
|
||||
EXTRA_DIST += windows-initguard.h windows-mutex.c windows-mutex.h
|
||||
|
||||
EXTRA_libgnu_la_SOURCES += windows-mutex.c
|
||||
|
||||
## end gnulib module windows-mutex
|
||||
|
||||
## begin gnulib module windows-once
|
||||
|
||||
|
||||
EXTRA_DIST += windows-once.c windows-once.h
|
||||
|
||||
EXTRA_libgnu_la_SOURCES += windows-once.c
|
||||
|
||||
## end gnulib module windows-once
|
||||
|
||||
## begin gnulib module windows-recmutex
|
||||
|
||||
|
||||
EXTRA_DIST += windows-initguard.h windows-recmutex.c windows-recmutex.h
|
||||
|
||||
EXTRA_libgnu_la_SOURCES += windows-recmutex.c
|
||||
|
||||
## end gnulib module windows-recmutex
|
||||
|
||||
## begin gnulib module windows-rwlock
|
||||
|
||||
|
||||
EXTRA_DIST += windows-initguard.h windows-rwlock.c windows-rwlock.h
|
||||
|
||||
EXTRA_libgnu_la_SOURCES += windows-rwlock.c
|
||||
|
||||
## end gnulib module windows-rwlock
|
||||
|
||||
## begin gnulib module xalloc
|
||||
|
||||
libgnu_la_SOURCES += xmalloc.c
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* A C macro for declaring that a function does not return.
|
||||
Copyright (C) 2011-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published
|
||||
|
|
@ -17,11 +17,21 @@
|
|||
#ifndef _Noreturn
|
||||
# if (defined __cplusplus \
|
||||
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
|
||||
|| (defined _MSC_VER && 1900 <= _MSC_VER)))
|
||||
|| (defined _MSC_VER && 1900 <= _MSC_VER)) \
|
||||
&& 0)
|
||||
/* [[noreturn]] is not practically usable, because with it the syntax
|
||||
extern _Noreturn void func (...);
|
||||
would not be valid; such a declaration would only be valid with 'extern'
|
||||
and '_Noreturn' swapped, or without the 'extern' keyword. However, some
|
||||
AIX system header files and several gnulib header files use precisely
|
||||
this syntax with 'extern'. */
|
||||
# define _Noreturn [[noreturn]]
|
||||
# elif ((!defined __cplusplus || defined __clang__) \
|
||||
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|
||||
|| 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
|
||||
|| 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
|
||||
|| (defined __apple_build_version__ \
|
||||
? 6000000 <= __apple_build_version__ \
|
||||
: 3 < __clang_major__ + (5 <= __clang_minor__))))
|
||||
/* _Noreturn works as-is. */
|
||||
# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
|
||||
# define _Noreturn __attribute__ ((__noreturn__))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Memory allocation on the stack.
|
||||
|
||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2019 Free Software Foundation,
|
||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2020 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* A C macro for declaring that specific arguments must not be NULL.
|
||||
Copyright (C) 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* argmatch.c -- find a match for a string in an array
|
||||
|
||||
Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2019 Free Software
|
||||
Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* argmatch.h -- definitions and prototypes for argmatch.c
|
||||
|
||||
Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2019 Free Software
|
||||
Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Default definition for ARGP_PROGRAM_BUG_ADDRESS.
|
||||
Copyright (C) 1996-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Default definition for ARGP_ERR_EXIT_STATUS
|
||||
Copyright (C) 1997, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 2009-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Word-wrapping and line-truncating streams
|
||||
Copyright (C) 1997-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Word-wrapping and line-truncating streams.
|
||||
Copyright (C) 1997-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Real definitions for extern inline functions in argp-fmtstream.h
|
||||
Copyright (C) 1997-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Hierarchical argument parsing help output
|
||||
Copyright (C) 1995-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Name frobnication for compiling argp outside of glibc
|
||||
Copyright (C) 1997-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Hierarchical argument parsing, layered over getopt
|
||||
Copyright (C) 1995-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Full and short program names for argp module
|
||||
Copyright (C) 2005, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Default definition for ARGP_PROGRAM_VERSION.
|
||||
Copyright (C) 1996-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Default definition for ARGP_PROGRAM_VERSION_HOOK.
|
||||
Copyright (C) 1996-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Real definitions for extern inline functions in argp.h
|
||||
Copyright (C) 1997-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Hierarchical argument parsing, layered over getopt.
|
||||
Copyright (C) 1995-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Formatted output to strings.
|
||||
Copyright (C) 1999, 2002, 2006, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2002, 2006, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* basename.c -- return the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2019 Free Software
|
||||
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* C++ compatible function declaration macros.
|
||||
Copyright (C) 2010-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published
|
||||
|
|
@ -301,9 +301,6 @@
|
|||
_GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
|
||||
"The symbol ::" #func " refers to the system function. " \
|
||||
"Use " #namespace "::" #func " instead.")
|
||||
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
|
||||
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
|
||||
extern __typeof__ (func) func
|
||||
# else
|
||||
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<ctype.h> functions' behaviour depends on the current locale set via
|
||||
setlocale.
|
||||
|
||||
Copyright (C) 2000-2003, 2006, 2008-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2003, 2006, 2008-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Case-insensitive string comparison functions in C locale.
|
||||
Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2019 Free Software
|
||||
Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* c-strcasecmp.c -- case insensitive string comparator in C locale
|
||||
Copyright (C) 1998-1999, 2005-2006, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998-1999, 2005-2006, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Optimized case-insensitive string comparison in C locale.
|
||||
Copyright (C) 2001-2002, 2007, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2002, 2007, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* c-strncasecmp.c -- case insensitive string comparator in C locale
|
||||
Copyright (C) 1998-1999, 2005-2006, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998-1999, 2005-2006, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Close a stream, with nicer error checking than fclose's.
|
||||
|
||||
Copyright (C) 1998-2002, 2004, 2006-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998-2002, 2004, 2006-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Close standard output and standard error, exiting with a diagnostic on error.
|
||||
|
||||
Copyright (C) 1998-2002, 2004, 2006, 2008-2019 Free Software Foundation,
|
||||
Copyright (C) 1998-2002, 2004, 2006, 2008-2020 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Close standard output and standard error.
|
||||
|
||||
Copyright (C) 1998, 2000, 2003-2004, 2006, 2008-2019 Free Software
|
||||
Copyright (C) 1998, 2000, 2003-2004, 2006, 2008-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -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-2019 Free Software
|
||||
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Take file names apart into directory and base names.
|
||||
|
||||
Copyright (C) 1998, 2001, 2003-2006, 2009-2019 Free Software Foundation,
|
||||
Copyright (C) 1998, 2001, 2003-2006, 2009-2020 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
# include <stdbool.h>
|
||||
# include <stddef.h>
|
||||
# include "dosname.h"
|
||||
# include "filename.h"
|
||||
|
||||
# ifndef DIRECTORY_SEPARATOR
|
||||
# define DIRECTORY_SEPARATOR '/'
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
/* File names on MS-DOS/Windows systems.
|
||||
|
||||
Copyright (C) 2000-2001, 2004-2006, 2009-2019 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
From Paul Eggert and Jim Meyering. */
|
||||
|
||||
#ifndef _DOSNAME_H
|
||||
#define _DOSNAME_H
|
||||
|
||||
#if (defined _WIN32 || defined __CYGWIN__ \
|
||||
|| defined __EMX__ || defined __MSDOS__ || defined __DJGPP__)
|
||||
/* This internal macro assumes ASCII, but all hosts that support drive
|
||||
letters use ASCII. */
|
||||
# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
|
||||
<= 'z' - 'a')
|
||||
# define FILE_SYSTEM_PREFIX_LEN(Filename) \
|
||||
(_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
|
||||
# ifndef __CYGWIN__
|
||||
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
|
||||
# endif
|
||||
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
|
||||
#else
|
||||
# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
|
||||
# define ISSLASH(C) ((C) == '/')
|
||||
#endif
|
||||
|
||||
#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
|
||||
#endif
|
||||
|
||||
#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
|
||||
# else
|
||||
# define IS_ABSOLUTE_FILE_NAME(F) \
|
||||
(ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
|
||||
#endif
|
||||
#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
|
||||
|
||||
#endif /* DOSNAME_H_ */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* A POSIX-like <errno.h>.
|
||||
|
||||
Copyright (C) 2008-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990-1998, 2000-2007, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1998, 2000-2007, 2009-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Declaration for error-reporting function
|
||||
Copyright (C) 1995-1997, 2003, 2006, 2008-2019 Free Software Foundation,
|
||||
Copyright (C) 1995-1997, 2003, 2006, 2008-2020 Free Software Foundation,
|
||||
Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2003, 2005-2007, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Like <fcntl.h>, but with non-working flags defined to 0.
|
||||
|
||||
Copyright (C) 2006-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -39,6 +39,12 @@
|
|||
#endif
|
||||
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
|
||||
|
||||
/* Native Windows platforms declare open(), creat() in <io.h>. */
|
||||
#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
|
||||
&& (defined _WIN32 && ! defined __CYGWIN__)
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#else
|
||||
/* Normal invocation convention. */
|
||||
|
||||
|
|
@ -59,6 +65,12 @@
|
|||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
|
||||
|
||||
/* Native Windows platforms declare open(), creat() in <io.h>. */
|
||||
#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
|
||||
&& (defined _WIN32 && ! defined __CYGWIN__)
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#ifndef _@GUARD_PREFIX@_FCNTL_H
|
||||
#define _@GUARD_PREFIX@_FCNTL_H
|
||||
|
||||
|
|
@ -66,12 +78,6 @@
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* Native Windows platforms declare open(), creat() in <io.h>. */
|
||||
#if (@GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
|
||||
&& (defined _WIN32 && ! defined __CYGWIN__)
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
|
|
@ -82,6 +88,26 @@
|
|||
|
||||
/* Declare overridden functions. */
|
||||
|
||||
#if @GNULIB_CREAT@
|
||||
# if @REPLACE_CREAT@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef creat
|
||||
# define creat rpl_creat
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (creat);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef creat
|
||||
/* Assume creat is always declared. */
|
||||
_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
|
||||
"use gnulib module creat for portability");
|
||||
#endif
|
||||
|
||||
#if @GNULIB_FCNTL@
|
||||
# if @REPLACE_FCNTL@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
|
|
@ -90,9 +116,15 @@
|
|||
# endif
|
||||
_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
|
||||
_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
|
||||
# if !GNULIB_defined_rpl_fcntl
|
||||
# define GNULIB_defined_rpl_fcntl 1
|
||||
# endif
|
||||
# else
|
||||
# if !@HAVE_FCNTL@
|
||||
_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
|
||||
# if !GNULIB_defined_fcntl
|
||||
# define GNULIB_defined_fcntl 1
|
||||
# endif
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
|
||||
# endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Basic filename support macros.
|
||||
Copyright (C) 2001-2004, 2007-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2004, 2007-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -14,38 +14,94 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* From Paul Eggert and Jim Meyering. */
|
||||
|
||||
#ifndef _FILENAME_H
|
||||
#define _FILENAME_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Pathname support.
|
||||
ISSLASH(C) tests whether C is a directory separator character.
|
||||
IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not,
|
||||
it may be concatenated to a directory pathname.
|
||||
IS_PATH_WITH_DIR(P) tests whether P contains a directory specification.
|
||||
/* Filename support.
|
||||
ISSLASH(C) tests whether C is a directory separator
|
||||
character.
|
||||
HAS_DEVICE(Filename) tests whether Filename contains a device
|
||||
specification.
|
||||
FILE_SYSTEM_PREFIX_LEN(Filename) length of the device specification
|
||||
at the beginning of Filename,
|
||||
index of the part consisting of
|
||||
alternating components and slashes.
|
||||
FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
1 when a non-empty device specification
|
||||
can be followed by an empty or relative
|
||||
part,
|
||||
0 when a non-empty device specification
|
||||
must be followed by a slash,
|
||||
0 when device specification don't exist.
|
||||
IS_ABSOLUTE_FILE_NAME(Filename)
|
||||
tests whether Filename is independent of
|
||||
any notion of "current directory".
|
||||
IS_RELATIVE_FILE_NAME(Filename)
|
||||
tests whether Filename may be concatenated
|
||||
to a directory filename.
|
||||
Note: On native Windows, OS/2, DOS, "c:" is neither an absolute nor a
|
||||
relative file name!
|
||||
IS_FILE_NAME_WITH_DIR(Filename) tests whether Filename contains a device
|
||||
or directory specification.
|
||||
*/
|
||||
#if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
|
||||
#if defined _WIN32 || defined __CYGWIN__ \
|
||||
|| defined __EMX__ || defined __MSDOS__ || defined __DJGPP__
|
||||
/* Native Windows, Cygwin, OS/2, DOS */
|
||||
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
|
||||
# define HAS_DEVICE(P) \
|
||||
((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
|
||||
&& (P)[1] == ':')
|
||||
# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
|
||||
# define IS_PATH_WITH_DIR(P) \
|
||||
(strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
|
||||
# define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
|
||||
/* Internal macro: Tests whether a character is a drive letter. */
|
||||
# define _IS_DRIVE_LETTER(C) \
|
||||
(((C) >= 'A' && (C) <= 'Z') || ((C) >= 'a' && (C) <= 'z'))
|
||||
/* Help the compiler optimizing it. This assumes ASCII. */
|
||||
# undef _IS_DRIVE_LETTER
|
||||
# define _IS_DRIVE_LETTER(C) \
|
||||
(((unsigned int) (C) | ('a' - 'A')) - 'a' <= 'z' - 'a')
|
||||
# define HAS_DEVICE(Filename) \
|
||||
(_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':')
|
||||
# define FILE_SYSTEM_PREFIX_LEN(Filename) (HAS_DEVICE (Filename) ? 2 : 0)
|
||||
# ifdef __CYGWIN__
|
||||
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
|
||||
# else
|
||||
/* On native Windows, OS/2, DOS, the system has the notion of a
|
||||
"current directory" on each drive. */
|
||||
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
|
||||
# endif
|
||||
# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
# define IS_ABSOLUTE_FILE_NAME(Filename) \
|
||||
ISSLASH ((Filename)[FILE_SYSTEM_PREFIX_LEN (Filename)])
|
||||
# else
|
||||
# define IS_ABSOLUTE_FILE_NAME(Filename) \
|
||||
(ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename))
|
||||
# endif
|
||||
# define IS_RELATIVE_FILE_NAME(Filename) \
|
||||
(! (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename)))
|
||||
# define IS_FILE_NAME_WITH_DIR(Filename) \
|
||||
(strchr ((Filename), '/') != NULL || strchr ((Filename), '\\') != NULL \
|
||||
|| HAS_DEVICE (Filename))
|
||||
#else
|
||||
/* Unix */
|
||||
# define ISSLASH(C) ((C) == '/')
|
||||
# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
|
||||
# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
|
||||
# define FILE_SYSTEM_PREFIX_LEN(P) 0
|
||||
# define HAS_DEVICE(Filename) ((void) (Filename), 0)
|
||||
# define FILE_SYSTEM_PREFIX_LEN(Filename) ((void) (Filename), 0)
|
||||
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
|
||||
# define IS_ABSOLUTE_FILE_NAME(Filename) ISSLASH ((Filename)[0])
|
||||
# define IS_RELATIVE_FILE_NAME(Filename) (! ISSLASH ((Filename)[0]))
|
||||
# define IS_FILE_NAME_WITH_DIR(Filename) (strchr ((Filename), '/') != NULL)
|
||||
#endif
|
||||
|
||||
/* Deprecated macros. For backward compatibility with old users of the
|
||||
'filename' module. */
|
||||
#define IS_ABSOLUTE_PATH IS_ABSOLUTE_FILE_NAME
|
||||
#define IS_PATH_WITH_DIR IS_FILE_NAME_WITH_DIR
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Supplemental information about the floating-point formats.
|
||||
Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007, 2009-2020 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2007.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Auxiliary definitions for <float.h>.
|
||||
Copyright (C) 2011-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011-2020 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2011.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* A correct <float.h>.
|
||||
|
||||
Copyright (C) 2007-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* fpending.c -- return the number of pending output bytes on a stream
|
||||
Copyright (C) 2000, 2004, 2006-2007, 2009-2019 Free Software Foundation,
|
||||
Copyright (C) 2000, 2004, 2006-2007, 2009-2020 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Declare __fpending.
|
||||
|
||||
Copyright (C) 2000, 2003, 2005-2006, 2009-2019 Free Software Foundation,
|
||||
Copyright (C) 2000, 2003, 2005-2006, 2009-2020 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* getopt-on-non-glibc compatibility macros.
|
||||
Copyright (C) 1989-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2020 Free Software Foundation, Inc.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Declarations for getopt (basic, portable features only).
|
||||
Copyright (C) 1989-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Declarations for getopt (GNU extensions).
|
||||
Copyright (C) 1989-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* getopt (basic, portable features) gnulib wrapper header.
|
||||
Copyright (C) 1989-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2020 Free Software Foundation, Inc.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library.
|
||||
|
|
@ -48,6 +48,14 @@
|
|||
# define optind __GETOPT_ID (optind)
|
||||
# define optopt __GETOPT_ID (optopt)
|
||||
|
||||
/* Work around a a problem on macOS, which declares getopt with a
|
||||
trailing __DARWIN_ALIAS(getopt) that would expand to something like
|
||||
__asm("_" "rpl_getopt" "$UNIX2003") were it not for the following
|
||||
hack to suppress the macOS declaration <https://bugs.gnu.org/40205>. */
|
||||
# ifdef __APPLE__
|
||||
# define _GETOPT
|
||||
# endif
|
||||
|
||||
/* The system's getopt.h may have already included getopt-core.h to
|
||||
declare the unprefixed identifiers. Undef _GETOPT_CORE_H so that
|
||||
getopt-core.h declares them with prefixes. */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* getopt (GNU extensions) gnulib wrapper header.
|
||||
Copyright (C) 1989-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2020 Free Software Foundation, Inc.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Getopt for GNU.
|
||||
Copyright (C) 1987-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Declarations for getopt.
|
||||
Copyright (C) 1989-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2020 Free Software Foundation, Inc.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library, which supplies a different version of
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Internal declarations for getopt.
|
||||
Copyright (C) 1989-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2020 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Program name management.
|
||||
Copyright (C) 2016-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2016-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Program name management.
|
||||
Copyright (C) 2016-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2016-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2019 Free Software
|
||||
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -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-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2003, 2005-2007, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,506 +0,0 @@
|
|||
/* Locking in multithreaded situations.
|
||||
Copyright (C) 2005-2019 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2005.
|
||||
Based on GCC's gthr-posix.h, gthr-posix95.h. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "glthread/lock.h"
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if USE_POSIX_THREADS
|
||||
|
||||
/* -------------------------- gl_lock_t datatype -------------------------- */
|
||||
|
||||
/* ------------------------- gl_rwlock_t datatype ------------------------- */
|
||||
|
||||
# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1)))
|
||||
|
||||
# ifdef PTHREAD_RWLOCK_INITIALIZER
|
||||
|
||||
# if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
|
||||
/* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
|
||||
|
||||
int
|
||||
glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock)
|
||||
{
|
||||
pthread_rwlockattr_t attributes;
|
||||
int err;
|
||||
|
||||
err = pthread_rwlockattr_init (&attributes);
|
||||
if (err != 0)
|
||||
return err;
|
||||
/* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that
|
||||
causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not
|
||||
do this; see
|
||||
http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */
|
||||
err = pthread_rwlockattr_setkind_np (&attributes,
|
||||
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
|
||||
if (err == 0)
|
||||
err = pthread_rwlock_init(lock, &attributes);
|
||||
/* pthread_rwlockattr_destroy always returns 0. It cannot influence the
|
||||
return value. */
|
||||
pthread_rwlockattr_destroy (&attributes);
|
||||
return err;
|
||||
}
|
||||
|
||||
# endif
|
||||
# else
|
||||
|
||||
int
|
||||
glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pthread_rwlock_init (&lock->rwlock, NULL);
|
||||
if (err != 0)
|
||||
return err;
|
||||
lock->initialized = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pthread_mutex_lock (&lock->guard);
|
||||
if (err != 0)
|
||||
return err;
|
||||
if (!lock->initialized)
|
||||
{
|
||||
err = glthread_rwlock_init_multithreaded (lock);
|
||||
if (err != 0)
|
||||
{
|
||||
pthread_mutex_unlock (&lock->guard);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
err = pthread_mutex_unlock (&lock->guard);
|
||||
if (err != 0)
|
||||
return err;
|
||||
}
|
||||
return pthread_rwlock_rdlock (&lock->rwlock);
|
||||
}
|
||||
|
||||
int
|
||||
glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pthread_mutex_lock (&lock->guard);
|
||||
if (err != 0)
|
||||
return err;
|
||||
if (!lock->initialized)
|
||||
{
|
||||
err = glthread_rwlock_init_multithreaded (lock);
|
||||
if (err != 0)
|
||||
{
|
||||
pthread_mutex_unlock (&lock->guard);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
err = pthread_mutex_unlock (&lock->guard);
|
||||
if (err != 0)
|
||||
return err;
|
||||
}
|
||||
return pthread_rwlock_wrlock (&lock->rwlock);
|
||||
}
|
||||
|
||||
int
|
||||
glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
return EINVAL;
|
||||
return pthread_rwlock_unlock (&lock->rwlock);
|
||||
}
|
||||
|
||||
int
|
||||
glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (!lock->initialized)
|
||||
return EINVAL;
|
||||
err = pthread_rwlock_destroy (&lock->rwlock);
|
||||
if (err != 0)
|
||||
return err;
|
||||
lock->initialized = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
int
|
||||
glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pthread_mutex_init (&lock->lock, NULL);
|
||||
if (err != 0)
|
||||
return err;
|
||||
err = pthread_cond_init (&lock->waiting_readers, NULL);
|
||||
if (err != 0)
|
||||
return err;
|
||||
err = pthread_cond_init (&lock->waiting_writers, NULL);
|
||||
if (err != 0)
|
||||
return err;
|
||||
lock->waiting_writers_count = 0;
|
||||
lock->runcount = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pthread_mutex_lock (&lock->lock);
|
||||
if (err != 0)
|
||||
return err;
|
||||
/* Test whether only readers are currently running, and whether the runcount
|
||||
field will not overflow, and whether no writer is waiting. The latter
|
||||
condition is because POSIX recommends that "write locks shall take
|
||||
precedence over read locks", to avoid "writer starvation". */
|
||||
while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
|
||||
{
|
||||
/* This thread has to wait for a while. Enqueue it among the
|
||||
waiting_readers. */
|
||||
err = pthread_cond_wait (&lock->waiting_readers, &lock->lock);
|
||||
if (err != 0)
|
||||
{
|
||||
pthread_mutex_unlock (&lock->lock);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
lock->runcount++;
|
||||
return pthread_mutex_unlock (&lock->lock);
|
||||
}
|
||||
|
||||
int
|
||||
glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pthread_mutex_lock (&lock->lock);
|
||||
if (err != 0)
|
||||
return err;
|
||||
/* Test whether no readers or writers are currently running. */
|
||||
while (!(lock->runcount == 0))
|
||||
{
|
||||
/* This thread has to wait for a while. Enqueue it among the
|
||||
waiting_writers. */
|
||||
lock->waiting_writers_count++;
|
||||
err = pthread_cond_wait (&lock->waiting_writers, &lock->lock);
|
||||
if (err != 0)
|
||||
{
|
||||
lock->waiting_writers_count--;
|
||||
pthread_mutex_unlock (&lock->lock);
|
||||
return err;
|
||||
}
|
||||
lock->waiting_writers_count--;
|
||||
}
|
||||
lock->runcount--; /* runcount becomes -1 */
|
||||
return pthread_mutex_unlock (&lock->lock);
|
||||
}
|
||||
|
||||
int
|
||||
glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pthread_mutex_lock (&lock->lock);
|
||||
if (err != 0)
|
||||
return err;
|
||||
if (lock->runcount < 0)
|
||||
{
|
||||
/* Drop a writer lock. */
|
||||
if (!(lock->runcount == -1))
|
||||
{
|
||||
pthread_mutex_unlock (&lock->lock);
|
||||
return EINVAL;
|
||||
}
|
||||
lock->runcount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Drop a reader lock. */
|
||||
if (!(lock->runcount > 0))
|
||||
{
|
||||
pthread_mutex_unlock (&lock->lock);
|
||||
return EINVAL;
|
||||
}
|
||||
lock->runcount--;
|
||||
}
|
||||
if (lock->runcount == 0)
|
||||
{
|
||||
/* POSIX recommends that "write locks shall take precedence over read
|
||||
locks", to avoid "writer starvation". */
|
||||
if (lock->waiting_writers_count > 0)
|
||||
{
|
||||
/* Wake up one of the waiting writers. */
|
||||
err = pthread_cond_signal (&lock->waiting_writers);
|
||||
if (err != 0)
|
||||
{
|
||||
pthread_mutex_unlock (&lock->lock);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wake up all waiting readers. */
|
||||
err = pthread_cond_broadcast (&lock->waiting_readers);
|
||||
if (err != 0)
|
||||
{
|
||||
pthread_mutex_unlock (&lock->lock);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pthread_mutex_unlock (&lock->lock);
|
||||
}
|
||||
|
||||
int
|
||||
glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pthread_mutex_destroy (&lock->lock);
|
||||
if (err != 0)
|
||||
return err;
|
||||
err = pthread_cond_destroy (&lock->waiting_readers);
|
||||
if (err != 0)
|
||||
return err;
|
||||
err = pthread_cond_destroy (&lock->waiting_writers);
|
||||
if (err != 0)
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
/* --------------------- gl_recursive_lock_t datatype --------------------- */
|
||||
|
||||
# if HAVE_PTHREAD_MUTEX_RECURSIVE
|
||||
|
||||
# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
||||
|
||||
int
|
||||
glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
|
||||
{
|
||||
pthread_mutexattr_t attributes;
|
||||
int err;
|
||||
|
||||
err = pthread_mutexattr_init (&attributes);
|
||||
if (err != 0)
|
||||
return err;
|
||||
err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
|
||||
if (err != 0)
|
||||
{
|
||||
pthread_mutexattr_destroy (&attributes);
|
||||
return err;
|
||||
}
|
||||
err = pthread_mutex_init (lock, &attributes);
|
||||
if (err != 0)
|
||||
{
|
||||
pthread_mutexattr_destroy (&attributes);
|
||||
return err;
|
||||
}
|
||||
err = pthread_mutexattr_destroy (&attributes);
|
||||
if (err != 0)
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
int
|
||||
glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
|
||||
{
|
||||
pthread_mutexattr_t attributes;
|
||||
int err;
|
||||
|
||||
err = pthread_mutexattr_init (&attributes);
|
||||
if (err != 0)
|
||||
return err;
|
||||
err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
|
||||
if (err != 0)
|
||||
{
|
||||
pthread_mutexattr_destroy (&attributes);
|
||||
return err;
|
||||
}
|
||||
err = pthread_mutex_init (&lock->recmutex, &attributes);
|
||||
if (err != 0)
|
||||
{
|
||||
pthread_mutexattr_destroy (&attributes);
|
||||
return err;
|
||||
}
|
||||
err = pthread_mutexattr_destroy (&attributes);
|
||||
if (err != 0)
|
||||
return err;
|
||||
lock->initialized = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pthread_mutex_lock (&lock->guard);
|
||||
if (err != 0)
|
||||
return err;
|
||||
if (!lock->initialized)
|
||||
{
|
||||
err = glthread_recursive_lock_init_multithreaded (lock);
|
||||
if (err != 0)
|
||||
{
|
||||
pthread_mutex_unlock (&lock->guard);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
err = pthread_mutex_unlock (&lock->guard);
|
||||
if (err != 0)
|
||||
return err;
|
||||
}
|
||||
return pthread_mutex_lock (&lock->recmutex);
|
||||
}
|
||||
|
||||
int
|
||||
glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
return EINVAL;
|
||||
return pthread_mutex_unlock (&lock->recmutex);
|
||||
}
|
||||
|
||||
int
|
||||
glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (!lock->initialized)
|
||||
return EINVAL;
|
||||
err = pthread_mutex_destroy (&lock->recmutex);
|
||||
if (err != 0)
|
||||
return err;
|
||||
lock->initialized = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
int
|
||||
glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pthread_mutex_init (&lock->mutex, NULL);
|
||||
if (err != 0)
|
||||
return err;
|
||||
lock->owner = (pthread_t) 0;
|
||||
lock->depth = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
|
||||
{
|
||||
pthread_t self = pthread_self ();
|
||||
if (lock->owner != self)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pthread_mutex_lock (&lock->mutex);
|
||||
if (err != 0)
|
||||
return err;
|
||||
lock->owner = self;
|
||||
}
|
||||
if (++(lock->depth) == 0) /* wraparound? */
|
||||
{
|
||||
lock->depth--;
|
||||
return EAGAIN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (lock->owner != pthread_self ())
|
||||
return EPERM;
|
||||
if (lock->depth == 0)
|
||||
return EINVAL;
|
||||
if (--(lock->depth) == 0)
|
||||
{
|
||||
lock->owner = (pthread_t) 0;
|
||||
return pthread_mutex_unlock (&lock->mutex);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (lock->owner != (pthread_t) 0)
|
||||
return EBUSY;
|
||||
return pthread_mutex_destroy (&lock->mutex);
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
/* -------------------------- gl_once_t datatype -------------------------- */
|
||||
|
||||
static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT;
|
||||
|
||||
int
|
||||
glthread_once_singlethreaded (pthread_once_t *once_control)
|
||||
{
|
||||
/* We don't know whether pthread_once_t is an integer type, a floating-point
|
||||
type, a pointer type, or a structure type. */
|
||||
char *firstbyte = (char *)once_control;
|
||||
if (*firstbyte == *(const char *)&fresh_once)
|
||||
{
|
||||
/* First time use of once_control. Invert the first byte. */
|
||||
*firstbyte = ~ *(const char *)&fresh_once;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if USE_WINDOWS_THREADS
|
||||
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
|
@ -1,666 +0,0 @@
|
|||
/* Locking in multithreaded situations.
|
||||
Copyright (C) 2005-2019 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2005.
|
||||
Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-win32.h. */
|
||||
|
||||
/* This file contains locking primitives for use with a given thread library.
|
||||
It does not contain primitives for creating threads or for other
|
||||
synchronization primitives.
|
||||
|
||||
Normal (non-recursive) locks:
|
||||
Type: gl_lock_t
|
||||
Declaration: gl_lock_define(extern, name)
|
||||
Initializer: gl_lock_define_initialized(, name)
|
||||
Initialization: gl_lock_init (name);
|
||||
Taking the lock: gl_lock_lock (name);
|
||||
Releasing the lock: gl_lock_unlock (name);
|
||||
De-initialization: gl_lock_destroy (name);
|
||||
Equivalent functions with control of error handling:
|
||||
Initialization: err = glthread_lock_init (&name);
|
||||
Taking the lock: err = glthread_lock_lock (&name);
|
||||
Releasing the lock: err = glthread_lock_unlock (&name);
|
||||
De-initialization: err = glthread_lock_destroy (&name);
|
||||
|
||||
Read-Write (non-recursive) locks:
|
||||
Type: gl_rwlock_t
|
||||
Declaration: gl_rwlock_define(extern, name)
|
||||
Initializer: gl_rwlock_define_initialized(, name)
|
||||
Initialization: gl_rwlock_init (name);
|
||||
Taking the lock: gl_rwlock_rdlock (name);
|
||||
gl_rwlock_wrlock (name);
|
||||
Releasing the lock: gl_rwlock_unlock (name);
|
||||
De-initialization: gl_rwlock_destroy (name);
|
||||
Equivalent functions with control of error handling:
|
||||
Initialization: err = glthread_rwlock_init (&name);
|
||||
Taking the lock: err = glthread_rwlock_rdlock (&name);
|
||||
err = glthread_rwlock_wrlock (&name);
|
||||
Releasing the lock: err = glthread_rwlock_unlock (&name);
|
||||
De-initialization: err = glthread_rwlock_destroy (&name);
|
||||
|
||||
Recursive locks:
|
||||
Type: gl_recursive_lock_t
|
||||
Declaration: gl_recursive_lock_define(extern, name)
|
||||
Initializer: gl_recursive_lock_define_initialized(, name)
|
||||
Initialization: gl_recursive_lock_init (name);
|
||||
Taking the lock: gl_recursive_lock_lock (name);
|
||||
Releasing the lock: gl_recursive_lock_unlock (name);
|
||||
De-initialization: gl_recursive_lock_destroy (name);
|
||||
Equivalent functions with control of error handling:
|
||||
Initialization: err = glthread_recursive_lock_init (&name);
|
||||
Taking the lock: err = glthread_recursive_lock_lock (&name);
|
||||
Releasing the lock: err = glthread_recursive_lock_unlock (&name);
|
||||
De-initialization: err = glthread_recursive_lock_destroy (&name);
|
||||
|
||||
Once-only execution:
|
||||
Type: gl_once_t
|
||||
Initializer: gl_once_define(extern, name)
|
||||
Execution: gl_once (name, initfunction);
|
||||
Equivalent functions with control of error handling:
|
||||
Execution: err = glthread_once (&name, initfunction);
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _LOCK_H
|
||||
#define _LOCK_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !defined c11_threads_in_use
|
||||
# if HAVE_THREADS_H && USE_POSIX_THREADS_WEAK
|
||||
# include <threads.h>
|
||||
# pragma weak thrd_exit
|
||||
# define c11_threads_in_use() (thrd_exit != NULL)
|
||||
# else
|
||||
# define c11_threads_in_use() 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if USE_POSIX_THREADS
|
||||
|
||||
/* Use the POSIX threads library. */
|
||||
|
||||
# include <pthread.h>
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# if PTHREAD_IN_USE_DETECTION_HARD
|
||||
|
||||
/* The pthread_in_use() detection needs to be done at runtime. */
|
||||
# define pthread_in_use() \
|
||||
glthread_in_use ()
|
||||
extern int glthread_in_use (void);
|
||||
|
||||
# endif
|
||||
|
||||
# if USE_POSIX_THREADS_WEAK
|
||||
|
||||
/* Use weak references to the POSIX threads library. */
|
||||
|
||||
/* Weak references avoid dragging in external libraries if the other parts
|
||||
of the program don't use them. Here we use them, because we don't want
|
||||
every program that uses libintl to depend on libpthread. This assumes
|
||||
that libpthread would not be loaded after libintl; i.e. if libintl is
|
||||
loaded first, by an executable that does not depend on libpthread, and
|
||||
then a module is dynamically loaded that depends on libpthread, libintl
|
||||
will not be multithread-safe. */
|
||||
|
||||
/* The way to test at runtime whether libpthread is present is to test
|
||||
whether a function pointer's value, such as &pthread_mutex_init, is
|
||||
non-NULL. However, some versions of GCC have a bug through which, in
|
||||
PIC mode, &foo != NULL always evaluates to true if there is a direct
|
||||
call to foo(...) in the same function. To avoid this, we test the
|
||||
address of a function in libpthread that we don't use. */
|
||||
|
||||
# pragma weak pthread_mutex_init
|
||||
# pragma weak pthread_mutex_lock
|
||||
# pragma weak pthread_mutex_unlock
|
||||
# pragma weak pthread_mutex_destroy
|
||||
# pragma weak pthread_rwlock_init
|
||||
# pragma weak pthread_rwlock_rdlock
|
||||
# pragma weak pthread_rwlock_wrlock
|
||||
# pragma weak pthread_rwlock_unlock
|
||||
# pragma weak pthread_rwlock_destroy
|
||||
# pragma weak pthread_once
|
||||
# pragma weak pthread_cond_init
|
||||
# pragma weak pthread_cond_wait
|
||||
# pragma weak pthread_cond_signal
|
||||
# pragma weak pthread_cond_broadcast
|
||||
# pragma weak pthread_cond_destroy
|
||||
# pragma weak pthread_mutexattr_init
|
||||
# pragma weak pthread_mutexattr_settype
|
||||
# pragma weak pthread_mutexattr_destroy
|
||||
# pragma weak pthread_rwlockattr_init
|
||||
# if __GNU_LIBRARY__ > 1
|
||||
# pragma weak pthread_rwlockattr_setkind_np
|
||||
# endif
|
||||
# pragma weak pthread_rwlockattr_destroy
|
||||
# ifndef pthread_self
|
||||
# pragma weak pthread_self
|
||||
# endif
|
||||
|
||||
# if !PTHREAD_IN_USE_DETECTION_HARD
|
||||
/* Considering all platforms with USE_POSIX_THREADS_WEAK, only few symbols
|
||||
can be used to determine whether libpthread is in use. These are:
|
||||
pthread_mutexattr_gettype
|
||||
pthread_rwlockattr_destroy
|
||||
pthread_rwlockattr_init
|
||||
*/
|
||||
# pragma weak pthread_mutexattr_gettype
|
||||
# define pthread_in_use() \
|
||||
(pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
# if !PTHREAD_IN_USE_DETECTION_HARD
|
||||
# define pthread_in_use() 1
|
||||
# endif
|
||||
|
||||
# endif
|
||||
|
||||
/* -------------------------- gl_lock_t datatype -------------------------- */
|
||||
|
||||
typedef pthread_mutex_t gl_lock_t;
|
||||
# define gl_lock_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS pthread_mutex_t NAME;
|
||||
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
|
||||
STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer;
|
||||
# define gl_lock_initializer \
|
||||
PTHREAD_MUTEX_INITIALIZER
|
||||
# define glthread_lock_init(LOCK) \
|
||||
(pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0)
|
||||
# define glthread_lock_lock(LOCK) \
|
||||
(pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
|
||||
# define glthread_lock_unlock(LOCK) \
|
||||
(pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
|
||||
# define glthread_lock_destroy(LOCK) \
|
||||
(pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
|
||||
|
||||
/* ------------------------- gl_rwlock_t datatype ------------------------- */
|
||||
|
||||
# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1)))
|
||||
|
||||
# ifdef PTHREAD_RWLOCK_INITIALIZER
|
||||
|
||||
typedef pthread_rwlock_t gl_rwlock_t;
|
||||
# define gl_rwlock_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS pthread_rwlock_t NAME;
|
||||
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
|
||||
STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer;
|
||||
# if HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
|
||||
# define gl_rwlock_initializer \
|
||||
PTHREAD_RWLOCK_INITIALIZER
|
||||
# define glthread_rwlock_init(LOCK) \
|
||||
(pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
|
||||
# else /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
|
||||
# define gl_rwlock_initializer \
|
||||
PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
|
||||
# define glthread_rwlock_init(LOCK) \
|
||||
(pthread_in_use () ? glthread_rwlock_init_for_glibc (LOCK) : 0)
|
||||
extern int glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock);
|
||||
# endif
|
||||
# define glthread_rwlock_rdlock(LOCK) \
|
||||
(pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0)
|
||||
# define glthread_rwlock_wrlock(LOCK) \
|
||||
(pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0)
|
||||
# define glthread_rwlock_unlock(LOCK) \
|
||||
(pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0)
|
||||
# define glthread_rwlock_destroy(LOCK) \
|
||||
(pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0)
|
||||
|
||||
# else
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int initialized;
|
||||
pthread_mutex_t guard; /* protects the initialization */
|
||||
pthread_rwlock_t rwlock; /* read-write lock */
|
||||
}
|
||||
gl_rwlock_t;
|
||||
# define gl_rwlock_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_rwlock_t NAME;
|
||||
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
|
||||
# define gl_rwlock_initializer \
|
||||
{ 0, PTHREAD_MUTEX_INITIALIZER }
|
||||
# define glthread_rwlock_init(LOCK) \
|
||||
(pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
|
||||
# define glthread_rwlock_rdlock(LOCK) \
|
||||
(pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
|
||||
# define glthread_rwlock_wrlock(LOCK) \
|
||||
(pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
|
||||
# define glthread_rwlock_unlock(LOCK) \
|
||||
(pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
|
||||
# define glthread_rwlock_destroy(LOCK) \
|
||||
(pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
|
||||
extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
|
||||
extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
|
||||
extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
|
||||
extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
|
||||
extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
|
||||
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
typedef struct
|
||||
{
|
||||
pthread_mutex_t lock; /* protects the remaining fields */
|
||||
pthread_cond_t waiting_readers; /* waiting readers */
|
||||
pthread_cond_t waiting_writers; /* waiting writers */
|
||||
unsigned int waiting_writers_count; /* number of waiting writers */
|
||||
int runcount; /* number of readers running, or -1 when a writer runs */
|
||||
}
|
||||
gl_rwlock_t;
|
||||
# define gl_rwlock_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_rwlock_t NAME;
|
||||
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
|
||||
# define gl_rwlock_initializer \
|
||||
{ PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 }
|
||||
# define glthread_rwlock_init(LOCK) \
|
||||
(pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
|
||||
# define glthread_rwlock_rdlock(LOCK) \
|
||||
(pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
|
||||
# define glthread_rwlock_wrlock(LOCK) \
|
||||
(pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
|
||||
# define glthread_rwlock_unlock(LOCK) \
|
||||
(pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
|
||||
# define glthread_rwlock_destroy(LOCK) \
|
||||
(pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
|
||||
extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
|
||||
extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
|
||||
extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
|
||||
extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
|
||||
extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
|
||||
|
||||
# endif
|
||||
|
||||
/* --------------------- gl_recursive_lock_t datatype --------------------- */
|
||||
|
||||
# if HAVE_PTHREAD_MUTEX_RECURSIVE
|
||||
|
||||
# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
||||
|
||||
typedef pthread_mutex_t gl_recursive_lock_t;
|
||||
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS pthread_mutex_t NAME;
|
||||
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
|
||||
STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer;
|
||||
# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER
|
||||
# define gl_recursive_lock_initializer \
|
||||
PTHREAD_RECURSIVE_MUTEX_INITIALIZER
|
||||
# else
|
||||
# define gl_recursive_lock_initializer \
|
||||
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
||||
# endif
|
||||
# define glthread_recursive_lock_init(LOCK) \
|
||||
(pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
|
||||
# define glthread_recursive_lock_lock(LOCK) \
|
||||
(pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
|
||||
# define glthread_recursive_lock_unlock(LOCK) \
|
||||
(pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
|
||||
# define glthread_recursive_lock_destroy(LOCK) \
|
||||
(pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
|
||||
extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
|
||||
|
||||
# else
|
||||
|
||||
typedef struct
|
||||
{
|
||||
pthread_mutex_t recmutex; /* recursive mutex */
|
||||
pthread_mutex_t guard; /* protects the initialization */
|
||||
int initialized;
|
||||
}
|
||||
gl_recursive_lock_t;
|
||||
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_recursive_lock_t NAME;
|
||||
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
|
||||
# define gl_recursive_lock_initializer \
|
||||
{ PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 }
|
||||
# define glthread_recursive_lock_init(LOCK) \
|
||||
(pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
|
||||
# define glthread_recursive_lock_lock(LOCK) \
|
||||
(pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
|
||||
# define glthread_recursive_lock_unlock(LOCK) \
|
||||
(pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
|
||||
# define glthread_recursive_lock_destroy(LOCK) \
|
||||
(pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
|
||||
extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
|
||||
extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
|
||||
extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
|
||||
extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
|
||||
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
/* Old versions of POSIX threads on Solaris did not have recursive locks.
|
||||
We have to implement them ourselves. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
pthread_mutex_t mutex;
|
||||
pthread_t owner;
|
||||
unsigned long depth;
|
||||
}
|
||||
gl_recursive_lock_t;
|
||||
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_recursive_lock_t NAME;
|
||||
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
|
||||
# define gl_recursive_lock_initializer \
|
||||
{ PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 }
|
||||
# define glthread_recursive_lock_init(LOCK) \
|
||||
(pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
|
||||
# define glthread_recursive_lock_lock(LOCK) \
|
||||
(pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
|
||||
# define glthread_recursive_lock_unlock(LOCK) \
|
||||
(pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
|
||||
# define glthread_recursive_lock_destroy(LOCK) \
|
||||
(pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
|
||||
extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
|
||||
extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
|
||||
extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
|
||||
extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
|
||||
|
||||
# endif
|
||||
|
||||
/* -------------------------- gl_once_t datatype -------------------------- */
|
||||
|
||||
typedef pthread_once_t gl_once_t;
|
||||
# define gl_once_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
|
||||
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
|
||||
(pthread_in_use () \
|
||||
? pthread_once (ONCE_CONTROL, INITFUNCTION) \
|
||||
: (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
|
||||
extern int glthread_once_singlethreaded (pthread_once_t *once_control);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if USE_WINDOWS_THREADS
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
|
||||
# include <windows.h>
|
||||
|
||||
# include "windows-mutex.h"
|
||||
# include "windows-rwlock.h"
|
||||
# include "windows-recmutex.h"
|
||||
# include "windows-once.h"
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/* We can use CRITICAL_SECTION directly, rather than the native Windows Event,
|
||||
Mutex, Semaphore types, because
|
||||
- we need only to synchronize inside a single process (address space),
|
||||
not inter-process locking,
|
||||
- we don't need to support trylock operations. (TryEnterCriticalSection
|
||||
does not work on Windows 95/98/ME. Packages that need trylock usually
|
||||
define their own mutex type.) */
|
||||
|
||||
/* There is no way to statically initialize a CRITICAL_SECTION. It needs
|
||||
to be done lazily, once only. For this we need spinlocks. */
|
||||
|
||||
/* -------------------------- gl_lock_t datatype -------------------------- */
|
||||
|
||||
typedef glwthread_mutex_t gl_lock_t;
|
||||
# define gl_lock_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_lock_t NAME;
|
||||
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_lock_t NAME = gl_lock_initializer;
|
||||
# define gl_lock_initializer \
|
||||
GLWTHREAD_MUTEX_INIT
|
||||
# define glthread_lock_init(LOCK) \
|
||||
(glwthread_mutex_init (LOCK), 0)
|
||||
# define glthread_lock_lock(LOCK) \
|
||||
glwthread_mutex_lock (LOCK)
|
||||
# define glthread_lock_unlock(LOCK) \
|
||||
glwthread_mutex_unlock (LOCK)
|
||||
# define glthread_lock_destroy(LOCK) \
|
||||
glwthread_mutex_destroy (LOCK)
|
||||
|
||||
/* ------------------------- gl_rwlock_t datatype ------------------------- */
|
||||
|
||||
typedef glwthread_rwlock_t gl_rwlock_t;
|
||||
# define gl_rwlock_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_rwlock_t NAME;
|
||||
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
|
||||
# define gl_rwlock_initializer \
|
||||
GLWTHREAD_RWLOCK_INIT
|
||||
# define glthread_rwlock_init(LOCK) \
|
||||
(glwthread_rwlock_init (LOCK), 0)
|
||||
# define glthread_rwlock_rdlock(LOCK) \
|
||||
glwthread_rwlock_rdlock (LOCK)
|
||||
# define glthread_rwlock_wrlock(LOCK) \
|
||||
glwthread_rwlock_wrlock (LOCK)
|
||||
# define glthread_rwlock_unlock(LOCK) \
|
||||
glwthread_rwlock_unlock (LOCK)
|
||||
# define glthread_rwlock_destroy(LOCK) \
|
||||
glwthread_rwlock_destroy (LOCK)
|
||||
|
||||
/* --------------------- gl_recursive_lock_t datatype --------------------- */
|
||||
|
||||
typedef glwthread_recmutex_t gl_recursive_lock_t;
|
||||
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_recursive_lock_t NAME;
|
||||
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
|
||||
# define gl_recursive_lock_initializer \
|
||||
GLWTHREAD_RECMUTEX_INIT
|
||||
# define glthread_recursive_lock_init(LOCK) \
|
||||
(glwthread_recmutex_init (LOCK), 0)
|
||||
# define glthread_recursive_lock_lock(LOCK) \
|
||||
glwthread_recmutex_lock (LOCK)
|
||||
# define glthread_recursive_lock_unlock(LOCK) \
|
||||
glwthread_recmutex_unlock (LOCK)
|
||||
# define glthread_recursive_lock_destroy(LOCK) \
|
||||
glwthread_recmutex_destroy (LOCK)
|
||||
|
||||
/* -------------------------- gl_once_t datatype -------------------------- */
|
||||
|
||||
typedef glwthread_once_t gl_once_t;
|
||||
# define gl_once_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_once_t NAME = GLWTHREAD_ONCE_INIT;
|
||||
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
|
||||
(glwthread_once (ONCE_CONTROL, INITFUNCTION), 0)
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if !(USE_POSIX_THREADS || USE_WINDOWS_THREADS)
|
||||
|
||||
/* Provide dummy implementation if threads are not supported. */
|
||||
|
||||
/* -------------------------- gl_lock_t datatype -------------------------- */
|
||||
|
||||
typedef int gl_lock_t;
|
||||
# define gl_lock_define(STORAGECLASS, NAME)
|
||||
# define gl_lock_define_initialized(STORAGECLASS, NAME)
|
||||
# define glthread_lock_init(NAME) 0
|
||||
# define glthread_lock_lock(NAME) 0
|
||||
# define glthread_lock_unlock(NAME) 0
|
||||
# define glthread_lock_destroy(NAME) 0
|
||||
|
||||
/* ------------------------- gl_rwlock_t datatype ------------------------- */
|
||||
|
||||
typedef int gl_rwlock_t;
|
||||
# define gl_rwlock_define(STORAGECLASS, NAME)
|
||||
# define gl_rwlock_define_initialized(STORAGECLASS, NAME)
|
||||
# define glthread_rwlock_init(NAME) 0
|
||||
# define glthread_rwlock_rdlock(NAME) 0
|
||||
# define glthread_rwlock_wrlock(NAME) 0
|
||||
# define glthread_rwlock_unlock(NAME) 0
|
||||
# define glthread_rwlock_destroy(NAME) 0
|
||||
|
||||
/* --------------------- gl_recursive_lock_t datatype --------------------- */
|
||||
|
||||
typedef int gl_recursive_lock_t;
|
||||
# define gl_recursive_lock_define(STORAGECLASS, NAME)
|
||||
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME)
|
||||
# define glthread_recursive_lock_init(NAME) 0
|
||||
# define glthread_recursive_lock_lock(NAME) 0
|
||||
# define glthread_recursive_lock_unlock(NAME) 0
|
||||
# define glthread_recursive_lock_destroy(NAME) 0
|
||||
|
||||
/* -------------------------- gl_once_t datatype -------------------------- */
|
||||
|
||||
typedef int gl_once_t;
|
||||
# define gl_once_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_once_t NAME = 0;
|
||||
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
|
||||
(*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0)
|
||||
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
/* Macros with built-in error handling. */
|
||||
|
||||
/* -------------------------- gl_lock_t datatype -------------------------- */
|
||||
|
||||
#define gl_lock_init(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_lock_init (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
#define gl_lock_lock(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_lock_lock (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
#define gl_lock_unlock(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_lock_unlock (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
#define gl_lock_destroy(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_lock_destroy (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* ------------------------- gl_rwlock_t datatype ------------------------- */
|
||||
|
||||
#define gl_rwlock_init(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_rwlock_init (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
#define gl_rwlock_rdlock(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_rwlock_rdlock (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
#define gl_rwlock_wrlock(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_rwlock_wrlock (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
#define gl_rwlock_unlock(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_rwlock_unlock (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
#define gl_rwlock_destroy(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_rwlock_destroy (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* --------------------- gl_recursive_lock_t datatype --------------------- */
|
||||
|
||||
#define gl_recursive_lock_init(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_recursive_lock_init (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
#define gl_recursive_lock_lock(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_recursive_lock_lock (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
#define gl_recursive_lock_unlock(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_recursive_lock_unlock (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
#define gl_recursive_lock_destroy(NAME) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_recursive_lock_destroy (&NAME)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* -------------------------- gl_once_t datatype -------------------------- */
|
||||
|
||||
#define gl_once(NAME, INITFUNCTION) \
|
||||
do \
|
||||
{ \
|
||||
if (glthread_once (&NAME, INITFUNCTION)) \
|
||||
abort (); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#endif /* _LOCK_H */
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
/* Multithreading primitives.
|
||||
Copyright (C) 2005-2019 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2005. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if USE_POSIX_THREADS
|
||||
|
||||
/* Use the POSIX threads library. */
|
||||
|
||||
# include <pthread.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
# if PTHREAD_IN_USE_DETECTION_HARD
|
||||
|
||||
/* The function to be executed by a dummy thread. */
|
||||
static void *
|
||||
dummy_thread_func (void *arg)
|
||||
{
|
||||
return arg;
|
||||
}
|
||||
|
||||
int
|
||||
glthread_in_use (void)
|
||||
{
|
||||
static int tested;
|
||||
static int result; /* 1: linked with -lpthread, 0: only with libc */
|
||||
|
||||
if (!tested)
|
||||
{
|
||||
pthread_t thread;
|
||||
|
||||
if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
|
||||
/* Thread creation failed. */
|
||||
result = 0;
|
||||
else
|
||||
{
|
||||
/* Thread creation works. */
|
||||
void *retval;
|
||||
if (pthread_join (thread, &retval) != 0)
|
||||
abort ();
|
||||
result = 1;
|
||||
}
|
||||
tested = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
/* This declaration is solely to ensure that after preprocessing
|
||||
this file is never empty. */
|
||||
typedef int dummy;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* hard-locale.c -- Determine whether a locale is hard.
|
||||
|
||||
Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2019 Free Software
|
||||
Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -21,52 +21,15 @@
|
|||
#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);
|
||||
char locale[SETLOCALE_NULL_MAX];
|
||||
|
||||
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;
|
||||
if (setlocale_null_r (category, locale, sizeof (locale)))
|
||||
return false;
|
||||
|
||||
/* Restore the caller's locale. */
|
||||
setlocale (category, locale);
|
||||
free (locale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hard;
|
||||
return !(strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Determine whether a locale is hard.
|
||||
|
||||
Copyright (C) 1999, 2003-2004, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2003-2004, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -20,6 +20,9 @@
|
|||
|
||||
# include <stdbool.h>
|
||||
|
||||
bool hard_locale (int);
|
||||
/* Return true if the specified CATEGORY of the current locale is hard, i.e.
|
||||
different from the C or POSIX locale that has a fixed behavior.
|
||||
CATEGORY must be one of the LC_* values, but not LC_ALL. */
|
||||
extern bool hard_locale (int category);
|
||||
|
||||
#endif /* HARD_LOCALE_H_ */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* intprops.h -- properties of integer types
|
||||
|
||||
Copyright (C) 2001-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published
|
||||
|
|
@ -22,19 +22,6 @@
|
|||
|
||||
#include <limits.h>
|
||||
|
||||
/* If the compiler lacks __has_builtin, define it well enough for this
|
||||
source file only. */
|
||||
#ifndef __has_builtin
|
||||
# define __has_builtin(x) _GL_HAS_##x
|
||||
# if 5 <= __GNUC__ && !defined __ICC
|
||||
# define _GL_HAS___builtin_add_overflow 1
|
||||
# else
|
||||
# define _GL_HAS___builtin_add_overflow 0
|
||||
# endif
|
||||
# define _GL_HAS___builtin_mul_overflow _GL_HAS___builtin_add_overflow
|
||||
# define _GL_TEMPDEF___has_builtin
|
||||
#endif
|
||||
|
||||
/* Return a value with the common real type of E and V and the value of V.
|
||||
Do not evaluate E. */
|
||||
#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
|
||||
|
|
@ -235,19 +222,20 @@
|
|||
|
||||
/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
|
||||
(A, B, P) work when P is non-null. */
|
||||
#if __has_builtin (__builtin_add_overflow)
|
||||
#if 5 <= __GNUC__ && !defined __ICC
|
||||
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
|
||||
#elif defined __has_builtin
|
||||
# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
|
||||
#else
|
||||
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
|
||||
#endif
|
||||
|
||||
/* True if __builtin_mul_overflow (A, B, P) works when P is non-null.
|
||||
Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
|
||||
#if (__has_builtin (__builtin_mul_overflow) \
|
||||
&& (!defined __clang__ || (defined __APPLE__ && defined __MACH__)))
|
||||
# define _GL_HAS_BUILTIN_MUL_OVERFLOW 1
|
||||
#else
|
||||
/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
|
||||
#ifdef __clang__
|
||||
/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
|
||||
# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
|
||||
#else
|
||||
# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
|
||||
#endif
|
||||
|
||||
/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
|
||||
|
|
@ -385,12 +373,17 @@
|
|||
_GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
|
||||
#endif
|
||||
#if _GL_HAS_BUILTIN_MUL_OVERFLOW
|
||||
/* Work around GCC bug 91450. */
|
||||
# define INT_MULTIPLY_WRAPV(a, b, r) \
|
||||
((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \
|
||||
&& _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
|
||||
? ((void) __builtin_mul_overflow (a, b, r), 1) \
|
||||
: __builtin_mul_overflow (a, b, r))
|
||||
# if (9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
|
||||
|| (__GNUC__ == 8 && 4 <= __GNUC_MINOR__))
|
||||
# define INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
|
||||
# else
|
||||
/* Work around GCC bug 91450. */
|
||||
# define INT_MULTIPLY_WRAPV(a, b, r) \
|
||||
((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \
|
||||
&& _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
|
||||
? ((void) __builtin_mul_overflow (a, b, r), 1) \
|
||||
: __builtin_mul_overflow (a, b, r))
|
||||
# endif
|
||||
#else
|
||||
# define INT_MULTIPLY_WRAPV(a, b, r) \
|
||||
_GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
|
||||
|
|
@ -588,11 +581,4 @@
|
|||
: (tmin) / (a) < (b)) \
|
||||
: (tmax) / (b) < (a)))
|
||||
|
||||
#ifdef _GL_TEMPDEF___has_builtin
|
||||
# undef __has_builtin
|
||||
# undef _GL_HAS___builtin_add_overflow
|
||||
# undef _GL_HAS___builtin_mul_overflow
|
||||
# undef _GL_TEMPDEF___has_builtin
|
||||
#endif
|
||||
|
||||
#endif /* _GL_INTPROPS_H */
|
||||
|
|
|
|||
1156
lib/inttypes.in.h
Normal file
1156
lib/inttypes.in.h
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,5 @@
|
|||
/* isatty() replacement.
|
||||
Copyright (C) 2012-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Replacement for 'int' to 'long double' conversion routine.
|
||||
Copyright (C) 2011-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011-2020 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2011.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
82
lib/lc-charset-dispatch.c
Normal file
82
lib/lc-charset-dispatch.c
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/* Dispatching based on the current locale's character encoding.
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2018. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "lc-charset-dispatch.h"
|
||||
|
||||
#if GNULIB_defined_mbstate_t
|
||||
|
||||
# include "localcharset.h"
|
||||
# include "streq.h"
|
||||
|
||||
# if GNULIB_WCHAR_SINGLE
|
||||
/* When we know that the locale does not change, provide a speedup by
|
||||
caching the value of locale_encoding_classification. */
|
||||
# define locale_encoding_classification_cached locale_encoding_classification
|
||||
# else
|
||||
/* By default, don't make assumptions, hence no caching. */
|
||||
# define locale_encoding_classification_uncached locale_encoding_classification
|
||||
# endif
|
||||
|
||||
# if GNULIB_WCHAR_SINGLE
|
||||
static inline
|
||||
# endif
|
||||
enc_t
|
||||
locale_encoding_classification_uncached (void)
|
||||
{
|
||||
const char *encoding = locale_charset ();
|
||||
if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
|
||||
return enc_utf8;
|
||||
if (STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
|
||||
return enc_eucjp;
|
||||
if (STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
|
||||
|| STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
|
||||
|| STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
|
||||
return enc_94;
|
||||
if (STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
|
||||
return enc_euctw;
|
||||
if (STREQ_OPT (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
|
||||
return enc_gb18030;
|
||||
if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
|
||||
return enc_sjis;
|
||||
return enc_other;
|
||||
}
|
||||
|
||||
# if GNULIB_WCHAR_SINGLE
|
||||
|
||||
static int cached_locale_enc = -1;
|
||||
|
||||
enc_t
|
||||
locale_encoding_classification_cached (void)
|
||||
{
|
||||
if (cached_locale_enc < 0)
|
||||
cached_locale_enc = locale_encoding_classification_uncached ();
|
||||
return cached_locale_enc;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
/* This declaration is solely to ensure that after preprocessing
|
||||
this file is never empty. */
|
||||
typedef int dummy;
|
||||
|
||||
#endif
|
||||
40
lib/lc-charset-dispatch.h
Normal file
40
lib/lc-charset-dispatch.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/* Dispatching based on the current locale's character encoding.
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2018. */
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
#if GNULIB_defined_mbstate_t
|
||||
|
||||
/* A classification of special values of the encoding of the current locale. */
|
||||
typedef enum
|
||||
{
|
||||
enc_other, /* other */
|
||||
enc_utf8, /* UTF-8 */
|
||||
enc_eucjp, /* EUC-JP */
|
||||
enc_94, /* EUC-KR, GB2312, BIG5 */
|
||||
enc_euctw, /* EUC-TW */
|
||||
enc_gb18030, /* GB18030 */
|
||||
enc_sjis /* SJIS */
|
||||
}
|
||||
enc_t;
|
||||
|
||||
/* Returns a classification of special values of the encoding of the current
|
||||
locale. */
|
||||
extern enc_t locale_encoding_classification (void);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* System definitions for code taken from the GNU C Library
|
||||
|
||||
Copyright 2017-2019 Free Software Foundation, Inc.
|
||||
Copyright 2017-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
|
|
@ -55,8 +55,17 @@
|
|||
|
||||
#ifndef __glibc_clang_prereq
|
||||
# if defined __clang_major__ && defined __clang_minor__
|
||||
# define __glibc_clang_prereq(maj, min) \
|
||||
((maj) < __clang_major__ + ((min) <= __clang_minor__))
|
||||
# ifdef __apple_build_version__
|
||||
/* Apple for some reason renumbers __clang_major__ and __clang_minor__.
|
||||
Gnulib code uses only __glibc_clang_prereq (3, 5); map it to
|
||||
6000000 <= __apple_build_version__. Support for other calls to
|
||||
__glibc_clang_prereq can be added here as needed. */
|
||||
# define __glibc_clang_prereq(maj, min) \
|
||||
((maj) == 3 && (min) == 5 ? 6000000 <= __apple_build_version__ : 0)
|
||||
# else
|
||||
# define __glibc_clang_prereq(maj, min) \
|
||||
((maj) < __clang_major__ + ((min) <= __clang_minor__))
|
||||
# endif
|
||||
# else
|
||||
# define __glibc_clang_prereq(maj, min) 0
|
||||
# endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* A GNU-like <limits.h>.
|
||||
|
||||
Copyright 2016-2019 Free Software Foundation, Inc.
|
||||
Copyright 2016-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Determine a canonical name for the current locale's character encoding.
|
||||
|
||||
Copyright (C) 2000-2006, 2008-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2006, 2008-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -58,6 +58,9 @@
|
|||
#elif defined WINDOWS_NATIVE
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
/* For the use of setlocale() below, the Gnulib override in setlocale.c is
|
||||
not needed; see the platform lists in setlocale_null.m4. */
|
||||
# undef setlocale
|
||||
#endif
|
||||
#if defined OS2
|
||||
# define INCL_DOS
|
||||
|
|
@ -150,7 +153,8 @@ static const struct table_entry alias_table[] =
|
|||
{ "ISO8859-2", "ISO-8859-2" },
|
||||
{ "ISO8859-4", "ISO-8859-4" },
|
||||
{ "ISO8859-5", "ISO-8859-5" },
|
||||
{ "ISO8859-7", "ISO-8859-7" }
|
||||
{ "ISO8859-7", "ISO-8859-7" },
|
||||
{ "US-ASCII", "ASCII" }
|
||||
# define alias_table_defined
|
||||
# endif
|
||||
# if defined __APPLE__ && defined __MACH__ /* Mac OS X */
|
||||
|
|
@ -378,8 +382,6 @@ static const struct table_entry alias_table[] =
|
|||
by Alex Taylor:
|
||||
<http://altsan.org/os2/toolkits/uls/index.html#codepages>.
|
||||
See also "__convcp() of kLIBC":
|
||||
<http://trac.netlabs.org/libc/browser/branches/libc-0.6/src/emx/src/lib/locale/__convcp.c>,
|
||||
or:
|
||||
<https://github.com/bitwiseworks/libc/blob/master/src/emx/src/lib/locale/__convcp.c>. */
|
||||
{ "CP1004", "CP1252" },
|
||||
/*{ "CP1041", "CP943" },*/
|
||||
|
|
@ -814,8 +816,11 @@ static const struct table_entry locale_table[] =
|
|||
|
||||
|
||||
/* Determine the current locale's character encoding, and canonicalize it
|
||||
into one of the canonical names listed in localcharset.h.
|
||||
The result must not be freed; it is statically allocated.
|
||||
into one of the canonical names listed below.
|
||||
The result must not be freed; it is statically allocated. The result
|
||||
becomes invalid when setlocale() is used to change the global locale, or
|
||||
when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
|
||||
is changed; threads in multithreaded programs should not do this.
|
||||
If the canonical name cannot be determined, the result is a non-canonical
|
||||
name. */
|
||||
|
||||
|
|
@ -827,6 +832,13 @@ locale_charset (void)
|
|||
{
|
||||
const char *codeset;
|
||||
|
||||
/* This function must be multithread-safe. To achieve this without using
|
||||
thread-local storage, we use a simple strcpy or memcpy to fill this static
|
||||
buffer. Filling it through, for example, strcpy + strcat would not be
|
||||
guaranteed to leave the buffer's contents intact if another thread is
|
||||
currently accessing it. If necessary, the contents is first assembled in
|
||||
a stack-allocated buffer. */
|
||||
|
||||
#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
|
||||
|
||||
# if HAVE_LANGINFO_CODESET
|
||||
|
|
@ -841,7 +853,7 @@ locale_charset (void)
|
|||
if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
|
||||
{
|
||||
const char *locale;
|
||||
static char buf[2 + 10 + 1];
|
||||
static char resultbuf[2 + 10 + 1];
|
||||
|
||||
locale = getenv ("LC_ALL");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
|
|
@ -865,11 +877,12 @@ locale_charset (void)
|
|||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
if (modifier - dot < sizeof (resultbuf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
/* This way of filling resultbuf is multithread-safe. */
|
||||
memcpy (resultbuf, dot, modifier - dot);
|
||||
resultbuf [modifier - dot] = '\0';
|
||||
return resultbuf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -885,8 +898,13 @@ locale_charset (void)
|
|||
converting to GetConsoleOutputCP(). This leads to correct results,
|
||||
except when SetConsoleOutputCP has been called and a raster font is
|
||||
in use. */
|
||||
sprintf (buf, "CP%u", GetACP ());
|
||||
codeset = buf;
|
||||
{
|
||||
char buf[2 + 10 + 1];
|
||||
|
||||
sprintf (buf, "CP%u", GetACP ());
|
||||
strcpy (resultbuf, buf);
|
||||
codeset = resultbuf;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
|
|
@ -896,34 +914,28 @@ locale_charset (void)
|
|||
|
||||
# elif defined WINDOWS_NATIVE
|
||||
|
||||
static char buf[2 + 10 + 1];
|
||||
char buf[2 + 10 + 1];
|
||||
static char resultbuf[2 + 10 + 1];
|
||||
|
||||
/* 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;
|
||||
char *current_locale = setlocale (LC_CTYPE, NULL);
|
||||
char *pdot = strrchr (current_locale, '.');
|
||||
|
||||
/* 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 && 2 + strlen (pdot + 1) + 1 <= sizeof (buf))
|
||||
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. */
|
||||
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 ());
|
||||
}
|
||||
/* For a locale name such as "French_France.65001", in Windows 10,
|
||||
|
|
@ -931,12 +943,15 @@ locale_charset (void)
|
|||
if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0)
|
||||
codeset = "UTF-8";
|
||||
else
|
||||
codeset = buf;
|
||||
{
|
||||
strcpy (resultbuf, buf);
|
||||
codeset = resultbuf;
|
||||
}
|
||||
|
||||
# elif defined OS2
|
||||
|
||||
const char *locale;
|
||||
static char buf[2 + 10 + 1];
|
||||
static char resultbuf[2 + 10 + 1];
|
||||
ULONG cp[3];
|
||||
ULONG cplen;
|
||||
|
||||
|
|
@ -965,11 +980,12 @@ locale_charset (void)
|
|||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
if (modifier - dot < sizeof (resultbuf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
/* This way of filling resultbuf is multithread-safe. */
|
||||
memcpy (resultbuf, dot, modifier - dot);
|
||||
resultbuf [modifier - dot] = '\0';
|
||||
return resultbuf;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -985,8 +1001,11 @@ locale_charset (void)
|
|||
codeset = "";
|
||||
else
|
||||
{
|
||||
char buf[2 + 10 + 1];
|
||||
|
||||
sprintf (buf, "CP%u", cp[0]);
|
||||
codeset = buf;
|
||||
strcpy (resultbuf, buf);
|
||||
codeset = resultbuf;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Determine a canonical name for the current locale's character encoding.
|
||||
Copyright (C) 2000-2003, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2003, 2009-2020 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
|
||||
|
|
@ -26,7 +26,10 @@ extern "C" {
|
|||
|
||||
/* Determine the current locale's character encoding, and canonicalize it
|
||||
into one of the canonical names listed below.
|
||||
The result must not be freed; it is statically allocated.
|
||||
The result must not be freed; it is statically allocated. The result
|
||||
becomes invalid when setlocale() is used to change the global locale, or
|
||||
when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
|
||||
is changed; threads in multithreaded programs should not do this.
|
||||
If the canonical name cannot be determined, the result is a non-canonical
|
||||
name. */
|
||||
extern const char * locale_charset (void);
|
||||
|
|
@ -45,15 +48,15 @@ extern const char * locale_charset (void);
|
|||
(darwin = Mac OS X, windows = native Windows)
|
||||
|
||||
ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin
|
||||
ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
|
||||
ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
|
||||
ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
||||
ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
||||
ISO-8859-3 Y glibc solaris cygwin
|
||||
ISO-8859-4 Y hpux osf solaris freebsd netbsd openbsd darwin
|
||||
ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
|
||||
ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
||||
ISO-8859-6 Y glibc aix hpux solaris cygwin
|
||||
ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
|
||||
ISO-8859-8 Y glibc aix hpux osf solaris cygwin
|
||||
ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin
|
||||
ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
||||
ISO-8859-8 Y glibc aix hpux osf solaris cygwin zos
|
||||
ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin zos
|
||||
ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin
|
||||
ISO-8859-14 glibc cygwin
|
||||
ISO-8859-15 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin
|
||||
|
|
@ -76,7 +79,7 @@ extern const char * locale_charset (void);
|
|||
CP874 windows dos
|
||||
CP922 aix
|
||||
CP932 aix cygwin windows dos
|
||||
CP943 aix
|
||||
CP943 aix zos
|
||||
CP949 osf darwin windows dos
|
||||
CP950 windows dos
|
||||
CP1046 aix
|
||||
|
|
@ -92,17 +95,17 @@ extern const char * locale_charset (void);
|
|||
CP1255 glibc windows
|
||||
CP1256 windows
|
||||
CP1257 windows
|
||||
GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin
|
||||
GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin zos
|
||||
EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
|
||||
EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
|
||||
EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin zos
|
||||
EUC-TW glibc aix hpux irix osf solaris netbsd
|
||||
BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin
|
||||
BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin zos
|
||||
BIG5-HKSCS glibc hpux solaris netbsd darwin
|
||||
GBK glibc aix osf solaris freebsd darwin cygwin windows dos
|
||||
GB18030 glibc hpux solaris freebsd netbsd darwin
|
||||
SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
|
||||
JOHAB glibc solaris windows
|
||||
TIS-620 glibc aix hpux osf solaris cygwin
|
||||
TIS-620 glibc aix hpux osf solaris cygwin zos
|
||||
VISCII Y glibc
|
||||
TCVN5712-1 glibc
|
||||
ARMSCII-8 glibc freebsd netbsd darwin
|
||||
|
|
@ -116,7 +119,7 @@ extern const char * locale_charset (void);
|
|||
HP-KANA8 hpux
|
||||
DEC-KANJI osf
|
||||
DEC-HANYU osf
|
||||
UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin
|
||||
UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin zos
|
||||
|
||||
Note: Names which are not marked as being a MIME name should not be used in
|
||||
Internet protocols for information interchange (mail, news, etc.).
|
||||
|
|
|
|||
305
lib/locale.in.h
Normal file
305
lib/locale.in.h
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
/* A POSIX <locale.h>.
|
||||
Copyright (C) 2007-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \
|
||||
|| defined _GL_ALREADY_INCLUDING_LOCALE_H
|
||||
|
||||
/* Special invocation convention:
|
||||
- Inside mingw header files,
|
||||
- To handle Solaris header files (through Solaris 10) when combined
|
||||
with gettext's libintl.h. */
|
||||
|
||||
#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
|
||||
|
||||
#else
|
||||
/* Normal invocation convention. */
|
||||
|
||||
#ifndef _@GUARD_PREFIX@_LOCALE_H
|
||||
|
||||
#define _GL_ALREADY_INCLUDING_LOCALE_H
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
|
||||
|
||||
#undef _GL_ALREADY_INCLUDING_LOCALE_H
|
||||
|
||||
#ifndef _@GUARD_PREFIX@_LOCALE_H
|
||||
#define _@GUARD_PREFIX@_LOCALE_H
|
||||
|
||||
/* NetBSD 5.0 mis-defines NULL. */
|
||||
#include <stddef.h>
|
||||
|
||||
/* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */
|
||||
#if @HAVE_XLOCALE_H@
|
||||
# include <xlocale.h>
|
||||
#endif
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||
|
||||
/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
|
||||
On systems that don't define it, use the same value as GNU libintl. */
|
||||
#if !defined LC_MESSAGES
|
||||
# define LC_MESSAGES 1729
|
||||
#endif
|
||||
|
||||
/* On native Windows with MSVC, 'struct lconv' lacks the members int_p_* and
|
||||
int_n_*. Instead of overriding 'struct lconv', merely define these member
|
||||
names as macros. This avoids trouble in C++ mode. */
|
||||
#if defined _MSC_VER
|
||||
# define int_p_cs_precedes p_cs_precedes
|
||||
# define int_p_sign_posn p_sign_posn
|
||||
# define int_p_sep_by_space p_sep_by_space
|
||||
# define int_n_cs_precedes n_cs_precedes
|
||||
# define int_n_sign_posn n_sign_posn
|
||||
# define int_n_sep_by_space n_sep_by_space
|
||||
#endif
|
||||
|
||||
/* Bionic libc's 'struct lconv' is just a dummy. */
|
||||
#if @REPLACE_STRUCT_LCONV@
|
||||
# define lconv rpl_lconv
|
||||
struct lconv
|
||||
{
|
||||
/* All 'char *' are actually 'const char *'. */
|
||||
|
||||
/* Members that depend on the LC_NUMERIC category of the locale. See
|
||||
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */
|
||||
|
||||
/* Symbol used as decimal point. */
|
||||
char *decimal_point;
|
||||
/* Symbol used to separate groups of digits to the left of the decimal
|
||||
point. */
|
||||
char *thousands_sep;
|
||||
/* Definition of the size of groups of digits to the left of the decimal
|
||||
point. */
|
||||
char *grouping;
|
||||
|
||||
/* Members that depend on the LC_MONETARY category of the locale. See
|
||||
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */
|
||||
|
||||
/* Symbol used as decimal point. */
|
||||
char *mon_decimal_point;
|
||||
/* Symbol used to separate groups of digits to the left of the decimal
|
||||
point. */
|
||||
char *mon_thousands_sep;
|
||||
/* Definition of the size of groups of digits to the left of the decimal
|
||||
point. */
|
||||
char *mon_grouping;
|
||||
/* Sign used to indicate a value >= 0. */
|
||||
char *positive_sign;
|
||||
/* Sign used to indicate a value < 0. */
|
||||
char *negative_sign;
|
||||
|
||||
/* For formatting local currency. */
|
||||
/* Currency symbol (3 characters) followed by separator (1 character). */
|
||||
char *currency_symbol;
|
||||
/* Number of digits after the decimal point. */
|
||||
char frac_digits;
|
||||
/* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
|
||||
comes after the number. */
|
||||
char p_cs_precedes;
|
||||
/* For values >= 0: Position of the sign. */
|
||||
char p_sign_posn;
|
||||
/* For values >= 0: Placement of spaces between currency symbol, sign, and
|
||||
number. */
|
||||
char p_sep_by_space;
|
||||
/* For values < 0: 1 if the currency symbol precedes the number, 0 if it
|
||||
comes after the number. */
|
||||
char n_cs_precedes;
|
||||
/* For values < 0: Position of the sign. */
|
||||
char n_sign_posn;
|
||||
/* For values < 0: Placement of spaces between currency symbol, sign, and
|
||||
number. */
|
||||
char n_sep_by_space;
|
||||
|
||||
/* For formatting international currency. */
|
||||
/* Currency symbol (3 characters) followed by separator (1 character). */
|
||||
char *int_curr_symbol;
|
||||
/* Number of digits after the decimal point. */
|
||||
char int_frac_digits;
|
||||
/* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
|
||||
comes after the number. */
|
||||
char int_p_cs_precedes;
|
||||
/* For values >= 0: Position of the sign. */
|
||||
char int_p_sign_posn;
|
||||
/* For values >= 0: Placement of spaces between currency symbol, sign, and
|
||||
number. */
|
||||
char int_p_sep_by_space;
|
||||
/* For values < 0: 1 if the currency symbol precedes the number, 0 if it
|
||||
comes after the number. */
|
||||
char int_n_cs_precedes;
|
||||
/* For values < 0: Position of the sign. */
|
||||
char int_n_sign_posn;
|
||||
/* For values < 0: Placement of spaces between currency symbol, sign, and
|
||||
number. */
|
||||
char int_n_sep_by_space;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if @GNULIB_LOCALECONV@
|
||||
# if @REPLACE_LOCALECONV@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef localeconv
|
||||
# define localeconv rpl_localeconv
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (localeconv, struct lconv *, (void));
|
||||
_GL_CXXALIAS_RPL (localeconv, struct lconv *, (void));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
|
||||
# endif
|
||||
# if __GLIBC__ >= 2
|
||||
_GL_CXXALIASWARN (localeconv);
|
||||
# endif
|
||||
#elif @REPLACE_STRUCT_LCONV@
|
||||
# undef localeconv
|
||||
# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef localeconv
|
||||
# if HAVE_RAW_DECL_LOCALECONV
|
||||
_GL_WARN_ON_USE (localeconv,
|
||||
"localeconv returns too few information on some platforms - "
|
||||
"use gnulib module localeconv for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if @GNULIB_SETLOCALE@
|
||||
# if @REPLACE_SETLOCALE@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef setlocale
|
||||
# define setlocale rpl_setlocale
|
||||
# define GNULIB_defined_setlocale 1
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale));
|
||||
_GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
|
||||
# endif
|
||||
# if __GLIBC__ >= 2
|
||||
_GL_CXXALIASWARN (setlocale);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef setlocale
|
||||
# if HAVE_RAW_DECL_SETLOCALE
|
||||
_GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
|
||||
"use gnulib module setlocale for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if @GNULIB_SETLOCALE_NULL@
|
||||
/* Included here for convenience. */
|
||||
# include "setlocale_null.h"
|
||||
#endif
|
||||
|
||||
#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_NEWLOCALE@)
|
||||
# if @REPLACE_NEWLOCALE@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef newlocale
|
||||
# define newlocale rpl_newlocale
|
||||
# define GNULIB_defined_newlocale 1
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (newlocale, locale_t,
|
||||
(int category_mask, const char *name, locale_t base)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
_GL_CXXALIAS_RPL (newlocale, locale_t,
|
||||
(int category_mask, const char *name, locale_t base));
|
||||
# else
|
||||
# if @HAVE_NEWLOCALE@
|
||||
_GL_CXXALIAS_SYS (newlocale, locale_t,
|
||||
(int category_mask, const char *name, locale_t base));
|
||||
# endif
|
||||
# endif
|
||||
# if @HAVE_NEWLOCALE@
|
||||
_GL_CXXALIASWARN (newlocale);
|
||||
# endif
|
||||
# if @HAVE_NEWLOCALE@ || @REPLACE_NEWLOCALE@
|
||||
# ifndef HAVE_WORKING_NEWLOCALE
|
||||
# define HAVE_WORKING_NEWLOCALE 1
|
||||
# endif
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef newlocale
|
||||
# if HAVE_RAW_DECL_NEWLOCALE
|
||||
_GL_WARN_ON_USE (newlocale, "newlocale is not portable");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @HAVE_DUPLOCALE@)
|
||||
# if @REPLACE_DUPLOCALE@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef duplocale
|
||||
# define duplocale rpl_duplocale
|
||||
# define GNULIB_defined_duplocale 1
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
|
||||
# else
|
||||
# if @HAVE_DUPLOCALE@
|
||||
_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
|
||||
# endif
|
||||
# endif
|
||||
# if @HAVE_DUPLOCALE@
|
||||
_GL_CXXALIASWARN (duplocale);
|
||||
# endif
|
||||
# if @HAVE_DUPLOCALE@ || @REPLACE_DUPLOCALE@
|
||||
# ifndef HAVE_WORKING_DUPLOCALE
|
||||
# define HAVE_WORKING_DUPLOCALE 1
|
||||
# endif
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef duplocale
|
||||
# if HAVE_RAW_DECL_DUPLOCALE
|
||||
_GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
|
||||
"use gnulib module duplocale for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_FREELOCALE@)
|
||||
# if @REPLACE_FREELOCALE@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef freelocale
|
||||
# define freelocale rpl_freelocale
|
||||
# define GNULIB_defined_freelocale 1
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (freelocale, void, (locale_t locale) _GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (freelocale, void, (locale_t locale));
|
||||
# else
|
||||
# if @HAVE_FREELOCALE@
|
||||
/* Need to cast, because on FreeBSD and Mac OS X 10.13, the return type is
|
||||
int. */
|
||||
_GL_CXXALIAS_SYS_CAST (freelocale, void, (locale_t locale));
|
||||
# endif
|
||||
# endif
|
||||
# if @HAVE_FREELOCALE@
|
||||
_GL_CXXALIASWARN (freelocale);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef freelocale
|
||||
# if HAVE_RAW_DECL_FREELOCALE
|
||||
_GL_WARN_ON_USE (freelocale, "freelocale is not portable");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* _@GUARD_PREFIX@_LOCALE_H */
|
||||
#endif /* _@GUARD_PREFIX@_LOCALE_H */
|
||||
#endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* Provide access to the last buffer returned by localtime() or gmtime().
|
||||
|
||||
Copyright (C) 2001-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2003, 2005-2007, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Provide access to the last buffer returned by localtime() or gmtime().
|
||||
|
||||
Copyright (C) 2001-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2003, 2005-2007, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Work around a bug of lstat on some systems
|
||||
|
||||
Copyright (C) 1997-2006, 2008-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2006, 2008-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* malloc() function that is glibc compatible.
|
||||
|
||||
Copyright (C) 1997-1998, 2006-2007, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-1998, 2006-2007, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Safe automatic memory allocation.
|
||||
Copyright (C) 2003, 2006-2007, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003, 2006-2007, 2009-2020 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2003, 2018.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Safe automatic memory allocation.
|
||||
Copyright (C) 2003-2007, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2007, 2009-2020 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2003.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -112,14 +112,10 @@ enum
|
|||
among all elementary types. */
|
||||
sa_alignment_long = sa_alignof (long),
|
||||
sa_alignment_double = sa_alignof (double),
|
||||
#if HAVE_LONG_LONG_INT
|
||||
sa_alignment_longlong = sa_alignof (long long),
|
||||
#endif
|
||||
sa_alignment_longdouble = sa_alignof (long double),
|
||||
sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
|
||||
#if HAVE_LONG_LONG_INT
|
||||
| (sa_alignment_longlong - 1)
|
||||
#endif
|
||||
| (sa_alignment_longdouble - 1)
|
||||
) + 1
|
||||
};
|
||||
|
|
|
|||
138
lib/mbrtowc-impl-utf8.h
Normal file
138
lib/mbrtowc-impl-utf8.h
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* Convert multibyte character to wide character.
|
||||
Copyright (C) 1999-2002, 2005-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2008. */
|
||||
|
||||
/* This file contains the part of the body of the mbrtowc and mbrtoc32 functions
|
||||
that handles the special case of the UTF-8 encoding. */
|
||||
|
||||
/* Cf. unistr/u8-mbtouc.c. */
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c < 0x80)
|
||||
{
|
||||
if (pwc != NULL)
|
||||
*pwc = c;
|
||||
res = (c == 0 ? 0 : 1);
|
||||
goto success;
|
||||
}
|
||||
if (c >= 0xc2)
|
||||
{
|
||||
if (c < 0xe0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
else /* m >= 2 */
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40)
|
||||
{
|
||||
if (pwc != NULL)
|
||||
*pwc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (c2 ^ 0x80);
|
||||
res = 2;
|
||||
goto success;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
else
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || c2 >= 0xa0)
|
||||
&& (c != 0xed || c2 < 0xa0))
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else /* m >= 3 */
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
|
||||
if ((c3 ^ 0x80) < 0x40)
|
||||
{
|
||||
unsigned int wc =
|
||||
(((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (c2 ^ 0x80) << 6)
|
||||
| (unsigned int) (c3 ^ 0x80));
|
||||
|
||||
if (FITS_IN_CHAR_TYPE (wc))
|
||||
{
|
||||
if (pwc != NULL)
|
||||
*pwc = wc;
|
||||
res = 3;
|
||||
goto success;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c <= 0xf4)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
else
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || c2 >= 0x90)
|
||||
&& (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
|
||||
if ((c3 ^ 0x80) < 0x40)
|
||||
{
|
||||
if (m == 3)
|
||||
goto incomplete;
|
||||
else /* m >= 4 */
|
||||
{
|
||||
unsigned char c4 = (unsigned char) p[3];
|
||||
|
||||
if ((c4 ^ 0x80) < 0x40)
|
||||
{
|
||||
unsigned int wc =
|
||||
(((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (c2 ^ 0x80) << 12)
|
||||
| ((unsigned int) (c3 ^ 0x80) << 6)
|
||||
| (unsigned int) (c4 ^ 0x80));
|
||||
|
||||
if (FITS_IN_CHAR_TYPE (wc))
|
||||
{
|
||||
if (pwc != NULL)
|
||||
*pwc = wc;
|
||||
res = 4;
|
||||
goto success;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
262
lib/mbrtowc-impl.h
Normal file
262
lib/mbrtowc-impl.h
Normal file
|
|
@ -0,0 +1,262 @@
|
|||
/* Convert multibyte character to wide character.
|
||||
Copyright (C) 1999-2002, 2005-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2008. */
|
||||
|
||||
/* This file contains the body of the mbrtowc and mbrtoc32 functions,
|
||||
when GNULIB_defined_mbstate_t is defined. */
|
||||
|
||||
char *pstate = (char *)ps;
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
pwc = NULL;
|
||||
s = "";
|
||||
n = 1;
|
||||
}
|
||||
|
||||
if (n == 0)
|
||||
return (size_t)(-2);
|
||||
|
||||
/* Here n > 0. */
|
||||
|
||||
if (pstate == NULL)
|
||||
pstate = internal_state;
|
||||
|
||||
{
|
||||
size_t nstate = pstate[0];
|
||||
char buf[4];
|
||||
const char *p;
|
||||
size_t m;
|
||||
enc_t enc;
|
||||
int res;
|
||||
|
||||
switch (nstate)
|
||||
{
|
||||
case 0:
|
||||
p = s;
|
||||
m = n;
|
||||
break;
|
||||
case 3:
|
||||
buf[2] = pstate[3];
|
||||
FALLTHROUGH;
|
||||
case 2:
|
||||
buf[1] = pstate[2];
|
||||
FALLTHROUGH;
|
||||
case 1:
|
||||
buf[0] = pstate[1];
|
||||
p = buf;
|
||||
m = nstate;
|
||||
buf[m++] = s[0];
|
||||
if (n >= 2 && m < 4)
|
||||
{
|
||||
buf[m++] = s[1];
|
||||
if (n >= 3 && m < 4)
|
||||
buf[m++] = s[2];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return (size_t)(-1);
|
||||
}
|
||||
|
||||
/* Here m > 0. */
|
||||
|
||||
enc = locale_encoding_classification ();
|
||||
|
||||
if (enc == enc_utf8) /* UTF-8 */
|
||||
{
|
||||
/* Achieve
|
||||
- multi-thread safety and
|
||||
- the ability to produce wide character values > WCHAR_MAX
|
||||
by not calling mbtowc() at all. */
|
||||
#include "mbrtowc-impl-utf8.h"
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The hidden internal state of mbtowc would make this function not
|
||||
multi-thread safe. Achieve multi-thread safety through a lock. */
|
||||
wchar_t wc;
|
||||
res = mbtowc_with_lock (&wc, p, m);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
if ((wc == 0) != (res == 0))
|
||||
abort ();
|
||||
if (pwc != NULL)
|
||||
*pwc = wc;
|
||||
goto success;
|
||||
}
|
||||
|
||||
/* mbtowc does not distinguish between invalid and incomplete multibyte
|
||||
sequences. But mbrtowc needs to make this distinction.
|
||||
There are two possible approaches:
|
||||
- Use iconv() and its return value.
|
||||
- Use built-in knowledge about the possible encodings.
|
||||
Given the low quality of implementation of iconv() on the systems
|
||||
that lack mbrtowc(), we use the second approach.
|
||||
The possible encodings are:
|
||||
- 8-bit encodings,
|
||||
- EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
|
||||
- UTF-8 (already handled above).
|
||||
Use specialized code for each. */
|
||||
if (m >= 4 || m >= MB_CUR_MAX)
|
||||
goto invalid;
|
||||
/* Here MB_CUR_MAX > 1 and 0 < m < 4. */
|
||||
switch (enc)
|
||||
{
|
||||
/* As a reference for this code, you can use the GNU libiconv
|
||||
implementation. Look for uses of the RET_TOOFEW macro. */
|
||||
|
||||
case enc_eucjp: /* EUC-JP */
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
|
||||
goto incomplete;
|
||||
}
|
||||
if (m == 2)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c == 0x8f)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if (c2 >= 0xa1 && c2 < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
case enc_94: /* EUC-KR, GB2312, BIG5 */
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0xa1 && c < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
case enc_euctw: /* EUC-TW */
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
case enc_gb18030: /* GB18030 */
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
|
||||
goto incomplete;
|
||||
}
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0x90 && c <= 0xe3)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if (c2 >= 0x30 && c2 <= 0x39)
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else /* m == 3 */
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
|
||||
if (c3 >= 0x81 && c3 <= 0xfe)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
case enc_sjis: /* SJIS */
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
|
||||
|| (c >= 0xf0 && c <= 0xf9))
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
default:
|
||||
/* An unknown multibyte encoding. */
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
|
||||
success:
|
||||
/* res >= 0 is the corrected return value of
|
||||
mbtowc_with_lock (&wc, p, m). */
|
||||
if (nstate >= (res > 0 ? res : 1))
|
||||
abort ();
|
||||
res -= nstate;
|
||||
pstate[0] = 0;
|
||||
return res;
|
||||
|
||||
incomplete:
|
||||
{
|
||||
size_t k = nstate;
|
||||
/* Here 0 <= k < m < 4. */
|
||||
pstate[++k] = s[0];
|
||||
if (k < m)
|
||||
{
|
||||
pstate[++k] = s[1];
|
||||
if (k < m)
|
||||
pstate[++k] = s[2];
|
||||
}
|
||||
if (k != m)
|
||||
abort ();
|
||||
}
|
||||
pstate[0] = m;
|
||||
return (size_t)(-2);
|
||||
|
||||
invalid:
|
||||
errno = EILSEQ;
|
||||
/* The conversion state is undefined, says POSIX. */
|
||||
return (size_t)(-1);
|
||||
}
|
||||
453
lib/mbrtowc.c
453
lib/mbrtowc.c
|
|
@ -1,5 +1,5 @@
|
|||
/* Convert multibyte character to wide character.
|
||||
Copyright (C) 1999-2002, 2005-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2002, 2005-2020 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,21 +20,39 @@
|
|||
/* 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(). */
|
||||
/* Implement mbrtowc() on top of mbtowc() for the non-UTF-8 locales
|
||||
and directly for the UTF-8 locales. */
|
||||
|
||||
# include <errno.h>
|
||||
# include <stdint.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
# include "localcharset.h"
|
||||
# include "streq.h"
|
||||
# if defined _WIN32 && !defined __CYGWIN__
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
|
||||
# include <windows.h>
|
||||
|
||||
# elif HAVE_PTHREAD_API
|
||||
|
||||
# include <pthread.h>
|
||||
# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
|
||||
# include <threads.h>
|
||||
# pragma weak thrd_exit
|
||||
# define c11_threads_in_use() (thrd_exit != NULL)
|
||||
# else
|
||||
# define c11_threads_in_use() 0
|
||||
# endif
|
||||
|
||||
# elif HAVE_THREADS_H
|
||||
|
||||
# include <threads.h>
|
||||
|
||||
# endif
|
||||
|
||||
# include "verify.h"
|
||||
# include "glthread/lock.h"
|
||||
# include "lc-charset-dispatch.h"
|
||||
# include "mbtowc-lock.h"
|
||||
|
||||
# ifndef FALLTHROUGH
|
||||
# if __GNUC__ < 7
|
||||
|
|
@ -44,417 +62,24 @@
|
|||
# endif
|
||||
# endif
|
||||
|
||||
/* Returns a classification of special values of the encoding of the current
|
||||
locale. */
|
||||
typedef enum {
|
||||
enc_other, /* other */
|
||||
enc_utf8, /* UTF-8 */
|
||||
enc_eucjp, /* EUC-JP */
|
||||
enc_94, /* EUC-KR, GB2312, BIG5 */
|
||||
enc_euctw, /* EUC-TW */
|
||||
enc_gb18030, /* GB18030 */
|
||||
enc_sjis /* SJIS */
|
||||
} enc_t;
|
||||
static inline enc_t
|
||||
locale_enc (void)
|
||||
{
|
||||
const char *encoding = locale_charset ();
|
||||
if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
|
||||
return enc_utf8;
|
||||
if (STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
|
||||
return enc_eucjp;
|
||||
if (STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
|
||||
|| STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
|
||||
|| STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
|
||||
return enc_94;
|
||||
if (STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
|
||||
return enc_euctw;
|
||||
if (STREQ_OPT (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
|
||||
return enc_gb18030;
|
||||
if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
|
||||
return enc_sjis;
|
||||
return enc_other;
|
||||
}
|
||||
|
||||
# if GNULIB_WCHAR_SINGLE
|
||||
/* When we know that the locale does not change, provide a speedup by
|
||||
caching the value of locale_enc. */
|
||||
static int cached_locale_enc = -1;
|
||||
static inline enc_t
|
||||
locale_enc_cached (void)
|
||||
{
|
||||
if (cached_locale_enc < 0)
|
||||
cached_locale_enc = locale_enc ();
|
||||
return cached_locale_enc;
|
||||
}
|
||||
# else
|
||||
/* By default, don't make assumptions, hence no caching. */
|
||||
# define locale_enc_cached locale_enc
|
||||
# endif
|
||||
|
||||
/* This lock protects the internal state of mbtowc against multiple simultaneous
|
||||
calls of mbrtowc. */
|
||||
gl_lock_define_initialized(static, mbtowc_lock)
|
||||
|
||||
verify (sizeof (mbstate_t) >= 4);
|
||||
|
||||
static char internal_state[4];
|
||||
|
||||
size_t
|
||||
mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
||||
{
|
||||
char *pstate = (char *)ps;
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
pwc = NULL;
|
||||
s = "";
|
||||
n = 1;
|
||||
}
|
||||
|
||||
if (n == 0)
|
||||
return (size_t)(-2);
|
||||
|
||||
/* Here n > 0. */
|
||||
|
||||
if (pstate == NULL)
|
||||
pstate = internal_state;
|
||||
|
||||
{
|
||||
size_t nstate = pstate[0];
|
||||
char buf[4];
|
||||
const char *p;
|
||||
size_t m;
|
||||
enc_t enc;
|
||||
int res;
|
||||
|
||||
switch (nstate)
|
||||
{
|
||||
case 0:
|
||||
p = s;
|
||||
m = n;
|
||||
break;
|
||||
case 3:
|
||||
buf[2] = pstate[3];
|
||||
FALLTHROUGH;
|
||||
case 2:
|
||||
buf[1] = pstate[2];
|
||||
FALLTHROUGH;
|
||||
case 1:
|
||||
buf[0] = pstate[1];
|
||||
p = buf;
|
||||
m = nstate;
|
||||
buf[m++] = s[0];
|
||||
if (n >= 2 && m < 4)
|
||||
{
|
||||
buf[m++] = s[1];
|
||||
if (n >= 3 && m < 4)
|
||||
buf[m++] = s[2];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return (size_t)(-1);
|
||||
}
|
||||
|
||||
/* Here m > 0. */
|
||||
|
||||
enc = locale_enc_cached ();
|
||||
|
||||
if (enc == enc_utf8) /* UTF-8 */
|
||||
{
|
||||
/* Achieve multi-thread safety by not calling mbtowc() at all. */
|
||||
/* Cf. unistr/u8-mbtouc.c. */
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c < 0x80)
|
||||
{
|
||||
if (pwc != NULL)
|
||||
*pwc = c;
|
||||
res = (c == 0 ? 0 : 1);
|
||||
goto success;
|
||||
}
|
||||
if (c >= 0xc2)
|
||||
{
|
||||
if (c < 0xe0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
else /* m >= 2 */
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40)
|
||||
{
|
||||
if (pwc != NULL)
|
||||
*pwc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (c2 ^ 0x80);
|
||||
res = 2;
|
||||
goto success;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
else
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || c2 >= 0xa0)
|
||||
&& (c != 0xed || c2 < 0xa0))
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else /* m >= 3 */
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
|
||||
if ((c3 ^ 0x80) < 0x40)
|
||||
{
|
||||
if (pwc != NULL)
|
||||
*pwc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (c2 ^ 0x80) << 6)
|
||||
| (unsigned int) (c3 ^ 0x80);
|
||||
res = 3;
|
||||
goto success;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c <= 0xf4)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
else
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || c2 >= 0x90)
|
||||
&& (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
|
||||
if ((c3 ^ 0x80) < 0x40)
|
||||
{
|
||||
if (m == 3)
|
||||
goto incomplete;
|
||||
else /* m >= 4 */
|
||||
{
|
||||
unsigned char c4 = (unsigned char) p[3];
|
||||
|
||||
if ((c4 ^ 0x80) < 0x40)
|
||||
{
|
||||
if (pwc != NULL)
|
||||
*pwc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (c2 ^ 0x80) << 12)
|
||||
| ((unsigned int) (c3 ^ 0x80) << 6)
|
||||
| (unsigned int) (c4 ^ 0x80);
|
||||
res = 4;
|
||||
goto success;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The hidden internal state of mbtowc would make this function not
|
||||
multi-thread safe. Achieve multi-thread safety through a lock. */
|
||||
gl_lock_lock (mbtowc_lock);
|
||||
|
||||
/* Put the hidden internal state of mbtowc into its initial state.
|
||||
This is needed at least with glibc, uClibc, and MSVC CRT.
|
||||
See <https://sourceware.org/bugzilla/show_bug.cgi?id=9674>. */
|
||||
mbtowc (NULL, NULL, 0);
|
||||
|
||||
res = mbtowc (pwc, p, m);
|
||||
|
||||
gl_lock_unlock (mbtowc_lock);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
if (pwc != NULL && ((*pwc == 0) != (res == 0)))
|
||||
abort ();
|
||||
goto success;
|
||||
}
|
||||
|
||||
/* mbtowc does not distinguish between invalid and incomplete multibyte
|
||||
sequences. But mbrtowc needs to make this distinction.
|
||||
There are two possible approaches:
|
||||
- Use iconv() and its return value.
|
||||
- Use built-in knowledge about the possible encodings.
|
||||
Given the low quality of implementation of iconv() on the systems
|
||||
that lack mbrtowc(), we use the second approach.
|
||||
The possible encodings are:
|
||||
- 8-bit encodings,
|
||||
- EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
|
||||
- UTF-8 (already handled above).
|
||||
Use specialized code for each. */
|
||||
if (m >= 4 || m >= MB_CUR_MAX)
|
||||
goto invalid;
|
||||
/* Here MB_CUR_MAX > 1 and 0 < m < 4. */
|
||||
switch (enc)
|
||||
{
|
||||
/* As a reference for this code, you can use the GNU libiconv
|
||||
implementation. Look for uses of the RET_TOOFEW macro. */
|
||||
|
||||
case enc_eucjp: /* EUC-JP */
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
|
||||
goto incomplete;
|
||||
}
|
||||
if (m == 2)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c == 0x8f)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if (c2 >= 0xa1 && c2 < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
case enc_94: /* EUC-KR, GB2312, BIG5 */
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0xa1 && c < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
case enc_euctw: /* EUC-TW */
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
case enc_gb18030: /* GB18030 */
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
|
||||
goto incomplete;
|
||||
}
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0x90 && c <= 0xe3)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if (c2 >= 0x30 && c2 <= 0x39)
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else /* m == 3 */
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
|
||||
if (c3 >= 0x81 && c3 <= 0xfe)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
case enc_sjis: /* SJIS */
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
|
||||
|| (c >= 0xf0 && c <= 0xf9))
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
default:
|
||||
/* An unknown multibyte encoding. */
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
|
||||
success:
|
||||
/* res >= 0 is the corrected return value of mbtowc (pwc, p, m). */
|
||||
if (nstate >= (res > 0 ? res : 1))
|
||||
abort ();
|
||||
res -= nstate;
|
||||
pstate[0] = 0;
|
||||
return res;
|
||||
|
||||
incomplete:
|
||||
{
|
||||
size_t k = nstate;
|
||||
/* Here 0 <= k < m < 4. */
|
||||
pstate[++k] = s[0];
|
||||
if (k < m)
|
||||
{
|
||||
pstate[++k] = s[1];
|
||||
if (k < m)
|
||||
pstate[++k] = s[2];
|
||||
}
|
||||
if (k != m)
|
||||
abort ();
|
||||
}
|
||||
pstate[0] = m;
|
||||
return (size_t)(-2);
|
||||
|
||||
invalid:
|
||||
errno = EILSEQ;
|
||||
/* The conversion state is undefined, says POSIX. */
|
||||
return (size_t)(-1);
|
||||
}
|
||||
# define FITS_IN_CHAR_TYPE(wc) ((wc) <= WCHAR_MAX)
|
||||
# include "mbrtowc-impl.h"
|
||||
}
|
||||
|
||||
#else
|
||||
/* Override the system's mbrtowc() function. */
|
||||
|
||||
# if MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ
|
||||
# include "hard-locale.h"
|
||||
# include <locale.h>
|
||||
# endif
|
||||
|
||||
# undef mbrtowc
|
||||
|
||||
size_t
|
||||
|
|
@ -512,14 +137,20 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
|||
}
|
||||
# endif
|
||||
|
||||
# if MBRTOWC_STORES_INCOMPLETE_BUG
|
||||
ret = mbrtowc (&wc, s, n, ps);
|
||||
if (ret < (size_t) -2 && pwc != NULL)
|
||||
*pwc = wc;
|
||||
# else
|
||||
ret = mbrtowc (pwc, s, n, ps);
|
||||
# endif
|
||||
|
||||
# if MBRTOWC_NUL_RETVAL_BUG
|
||||
if (ret < (size_t) -2 && !*pwc)
|
||||
return 0;
|
||||
# endif
|
||||
|
||||
# if C_LOCALE_MAYBE_EILSEQ
|
||||
# if MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ
|
||||
if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE))
|
||||
{
|
||||
unsigned char uc = *s;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Test for initial conversion state.
|
||||
Copyright (C) 2008-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008-2020 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2008.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -56,13 +56,10 @@ mbsinit (const mbstate_t *ps)
|
|||
{
|
||||
# if defined _WIN32 && !defined __CYGWIN__
|
||||
/* Native Windows. */
|
||||
# ifdef __MINGW32__
|
||||
/* On mingw, 'mbstate_t' is defined as 'int'. */
|
||||
return ps == NULL || *ps == 0;
|
||||
# else
|
||||
/* MSVC defines 'mbstate_t' as an 8-byte struct; the first 4-bytes matter. */
|
||||
/* MSVC defines 'mbstate_t' as an 8-byte struct; the first 4 bytes matter.
|
||||
On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined as
|
||||
an 8-byte struct, of which the first 4 bytes matter. */
|
||||
return ps == NULL || *(const unsigned int *)ps == 0;
|
||||
# endif
|
||||
# else
|
||||
/* Minix, HP-UX 11.00, Solaris 2.6, Interix, ... */
|
||||
/* Maybe this definition works, maybe not... */
|
||||
|
|
|
|||
150
lib/mbtowc-lock.c
Normal file
150
lib/mbtowc-lock.c
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/* Return the internal lock used by mbrtowc and mbrtoc32.
|
||||
Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2019-2020. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* When it is known that the gl_get_mbtowc_lock function is defined
|
||||
by a dependency library, it should not be defined here. */
|
||||
#if OMIT_MBTOWC_LOCK
|
||||
|
||||
/* This declaration is solely to ensure that after preprocessing
|
||||
this file is never empty. */
|
||||
typedef int dummy;
|
||||
|
||||
#else
|
||||
|
||||
/* This file defines the internal lock used by mbrtowc and mbrtoc32.
|
||||
It is a separate compilation unit, so that only one copy of it is
|
||||
present when linking statically. */
|
||||
|
||||
/* Prohibit renaming this symbol. */
|
||||
# undef gl_get_mbtowc_lock
|
||||
|
||||
/* Macro for exporting a symbol (function, not variable) defined in this file,
|
||||
when compiled into a shared library. */
|
||||
# ifndef DLL_EXPORTED
|
||||
# if HAVE_VISIBILITY
|
||||
/* Override the effect of the compiler option '-fvisibility=hidden'. */
|
||||
# define DLL_EXPORTED __attribute__((__visibility__("default")))
|
||||
# elif defined _WIN32 || defined __CYGWIN__
|
||||
# define DLL_EXPORTED __declspec(dllexport)
|
||||
# else
|
||||
# define DLL_EXPORTED
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined _WIN32 && !defined __CYGWIN__
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
|
||||
# include <windows.h>
|
||||
|
||||
# include "windows-initguard.h"
|
||||
|
||||
/* The return type is a 'CRITICAL_SECTION *', not a 'glwthread_mutex_t *',
|
||||
because the latter is not guaranteed to be a stable ABI in the future. */
|
||||
|
||||
/* Make sure the function gets exported from DLLs. */
|
||||
DLL_EXPORTED CRITICAL_SECTION *gl_get_mbtowc_lock (void);
|
||||
|
||||
static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
|
||||
static CRITICAL_SECTION lock;
|
||||
|
||||
/* Returns the internal lock used by mbrtowc and mbrtoc32. */
|
||||
CRITICAL_SECTION *
|
||||
gl_get_mbtowc_lock (void)
|
||||
{
|
||||
if (!guard.done)
|
||||
{
|
||||
if (InterlockedIncrement (&guard.started) == 0)
|
||||
{
|
||||
/* This thread is the first one to need the lock. Initialize it. */
|
||||
InitializeCriticalSection (&lock);
|
||||
guard.done = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Don't let guard.started grow and wrap around. */
|
||||
InterlockedDecrement (&guard.started);
|
||||
/* Yield the CPU while waiting for another thread to finish
|
||||
initializing this mutex. */
|
||||
while (!guard.done)
|
||||
Sleep (0);
|
||||
}
|
||||
}
|
||||
return &lock;
|
||||
}
|
||||
|
||||
# elif HAVE_PTHREAD_API
|
||||
|
||||
# include <pthread.h>
|
||||
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
/* Make sure the function gets exported from shared libraries. */
|
||||
DLL_EXPORTED pthread_mutex_t *gl_get_mbtowc_lock (void);
|
||||
|
||||
/* Returns the internal lock used by mbrtowc and mbrtoc32. */
|
||||
pthread_mutex_t *
|
||||
gl_get_mbtowc_lock (void)
|
||||
{
|
||||
return &mutex;
|
||||
}
|
||||
|
||||
# elif HAVE_THREADS_H
|
||||
|
||||
# include <threads.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
static int volatile init_needed = 1;
|
||||
static once_flag init_once = ONCE_FLAG_INIT;
|
||||
static mtx_t mutex;
|
||||
|
||||
static void
|
||||
atomic_init (void)
|
||||
{
|
||||
if (mtx_init (&mutex, mtx_plain) != thrd_success)
|
||||
abort ();
|
||||
init_needed = 0;
|
||||
}
|
||||
|
||||
/* Make sure the function gets exported from shared libraries. */
|
||||
DLL_EXPORTED mtx_t *gl_get_mbtowc_lock (void);
|
||||
|
||||
/* Returns the internal lock used by mbrtowc and mbrtoc32. */
|
||||
mtx_t *
|
||||
gl_get_mbtowc_lock (void)
|
||||
{
|
||||
if (init_needed)
|
||||
call_once (&init_once, atomic_init);
|
||||
return &mutex;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
# if (defined _WIN32 || defined __CYGWIN__) && !defined _MSC_VER
|
||||
/* Make sure the '__declspec(dllimport)' in mbrtowc.c and mbrtoc32.c does not
|
||||
cause a link failure when no DLLs are involved. */
|
||||
# if defined _WIN64 || defined _LP64
|
||||
# define IMP(x) __imp_##x
|
||||
# else
|
||||
# define IMP(x) _imp__##x
|
||||
# endif
|
||||
void * IMP(gl_get_mbtowc_lock) = &gl_get_mbtowc_lock;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
115
lib/mbtowc-lock.h
Normal file
115
lib/mbtowc-lock.h
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/* Use the internal lock used by mbrtowc and mbrtoc32.
|
||||
Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2019-2020. */
|
||||
|
||||
/* Use a lock, so that no two threads can invoke mbtowc at the same time. */
|
||||
|
||||
static inline int
|
||||
mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m)
|
||||
{
|
||||
/* Put the hidden internal state of mbtowc into its initial state.
|
||||
This is needed at least with glibc, uClibc, and MSVC CRT.
|
||||
See <https://sourceware.org/bugzilla/show_bug.cgi?id=9674>. */
|
||||
mbtowc (NULL, NULL, 0);
|
||||
|
||||
return mbtowc (pwc, p, m);
|
||||
}
|
||||
|
||||
/* Prohibit renaming this symbol. */
|
||||
#undef gl_get_mbtowc_lock
|
||||
|
||||
#if defined _WIN32 && !defined __CYGWIN__
|
||||
|
||||
extern __declspec(dllimport) CRITICAL_SECTION *gl_get_mbtowc_lock (void);
|
||||
|
||||
static int
|
||||
mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
|
||||
{
|
||||
CRITICAL_SECTION *lock = gl_get_mbtowc_lock ();
|
||||
int ret;
|
||||
|
||||
EnterCriticalSection (lock);
|
||||
ret = mbtowc_unlocked (pwc, p, m);
|
||||
LeaveCriticalSection (lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#elif HAVE_PTHREAD_API /* AIX, IRIX, Cygwin */
|
||||
|
||||
extern
|
||||
# if defined _WIN32 || defined __CYGWIN__
|
||||
__declspec(dllimport)
|
||||
# endif
|
||||
pthread_mutex_t *gl_get_mbtowc_lock (void);
|
||||
|
||||
# if HAVE_WEAK_SYMBOLS /* IRIX */
|
||||
|
||||
/* Avoid the need to link with '-lpthread'. */
|
||||
# pragma weak pthread_mutex_lock
|
||||
# pragma weak pthread_mutex_unlock
|
||||
|
||||
/* Determine whether libpthread is in use. */
|
||||
# pragma weak pthread_mutexattr_gettype
|
||||
/* See the comments in lock.h. */
|
||||
# define pthread_in_use() \
|
||||
(pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
|
||||
|
||||
# else
|
||||
# define pthread_in_use() 1
|
||||
# endif
|
||||
|
||||
static int
|
||||
mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
|
||||
{
|
||||
if (pthread_in_use())
|
||||
{
|
||||
pthread_mutex_t *lock = gl_get_mbtowc_lock ();
|
||||
int ret;
|
||||
|
||||
if (pthread_mutex_lock (lock))
|
||||
abort ();
|
||||
ret = mbtowc_unlocked (pwc, p, m);
|
||||
if (pthread_mutex_unlock (lock))
|
||||
abort ();
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
return mbtowc_unlocked (pwc, p, m);
|
||||
}
|
||||
|
||||
#elif HAVE_THREADS_H
|
||||
|
||||
extern mtx_t *gl_get_mbtowc_lock (void);
|
||||
|
||||
static int
|
||||
mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
|
||||
{
|
||||
mtx_t *lock = gl_get_mbtowc_lock ();
|
||||
int ret;
|
||||
|
||||
if (mtx_lock (lock) != thrd_success)
|
||||
abort ();
|
||||
ret = mbtowc_unlocked (pwc, p, m);
|
||||
if (mtx_unlock (lock) != thrd_success)
|
||||
abort ();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2019
|
||||
/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2020
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Suppress a valgrind message about use of uninitialized memory in memchr().
|
||||
|
||||
# Copyright (C) 2009-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2009-2020 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Copy memory area and return pointer after last written byte.
|
||||
Copyright (C) 2003, 2007, 2009-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003, 2007, 2009-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* MIN, MAX macros.
|
||||
Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2019 Free Software
|
||||
Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -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-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001, 2003, 2006, 2008-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2019 Free Software
|
||||
/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
This file is derived from the one in the GNU C Library.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2019 Free Software
|
||||
/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
This file is derived from the one in the GNU C Library.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Invalid parameter handler for MSVC runtime libraries.
|
||||
Copyright (C) 2011-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Invalid parameter handler for MSVC runtime libraries.
|
||||
Copyright (C) 2011-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Wrappers that don't throw invalid parameter notifications
|
||||
with MSVC runtime libraries.
|
||||
Copyright (C) 2011-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Wrappers that don't throw invalid parameter notifications
|
||||
with MSVC runtime libraries.
|
||||
Copyright (C) 2011-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011-2020 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Define PATH_MAX somehow. Requires sys/types.h.
|
||||
Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2019 Free Software
|
||||
Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename,
|
||||
including the terminating NUL byte.
|
||||
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html>
|
||||
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html>
|
||||
PATH_MAX is not defined on systems which have no limit on filename length,
|
||||
such as GNU/Hurd.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Decomposed printf argument list.
|
||||
Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2019 Free Software
|
||||
Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -65,14 +65,12 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
|
|||
case TYPE_ULONGINT:
|
||||
ap->a.a_ulongint = va_arg (args, unsigned long int);
|
||||
break;
|
||||
#if HAVE_LONG_LONG_INT
|
||||
case TYPE_LONGLONGINT:
|
||||
ap->a.a_longlongint = va_arg (args, long long int);
|
||||
break;
|
||||
case TYPE_ULONGLONGINT:
|
||||
ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
|
||||
break;
|
||||
#endif
|
||||
case TYPE_DOUBLE:
|
||||
ap->a.a_double = va_arg (args, double);
|
||||
break;
|
||||
|
|
@ -135,11 +133,9 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
|
|||
case TYPE_COUNT_LONGINT_POINTER:
|
||||
ap->a.a_count_longint_pointer = va_arg (args, long int *);
|
||||
break;
|
||||
#if HAVE_LONG_LONG_INT
|
||||
case TYPE_COUNT_LONGLONGINT_POINTER:
|
||||
ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
|
||||
break;
|
||||
#endif
|
||||
#if ENABLE_UNISTDIO
|
||||
/* The unistdio extensions. */
|
||||
case TYPE_U8_STRING:
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue